android中fragmenttabhost+fragment+fragmentActivity的逻辑问题
ringa_lee
ringa_lee 2017-04-17 12:02:22
0
2
171

框架为:主类继承fragmentActivity,XML文件为fragmenttabhost+fragment+radiobutton的一个底部导航栏,点击radioButton动态切换fragment...
问题:在子fragment中,如何实现其加载的view的控件逻辑呢?我知道有些简单的可以view.findviewbyid()...
有些控件实例化需要上下文this,可是这个类继承的并不是Activity,而是fragment,并不适用上下文this,请问这时该如何实现其子fragment中view的控件逻辑?

ringa_lee
ringa_lee

ringa_lee

reply all (2)
Peter_Zhu

在你的fragment中拿到你想要的view即可

public class YourFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.details, container, false); Button button = (Button) view.findViewById(R.id.your_button); button.setOnClickListener(...); return view; }
    洪涛

    请问解决了吗? 我也遇到这个问题了。715393162 谢谢~

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!