How to access parent Activity View in Fragment

前端 未结 4 1064
刺人心
刺人心 2021-01-31 06:58

I have an ActionBarActivity and fragment. I am using FragmentPagerAdapter that provides fragment to my app. My question How can I access parent Activit

4条回答
  •  别那么骄傲
    2021-01-31 07:44

    You can use

    View view = getActivity().findViewById(R.id.viewid);
    

    Quoting docs

    Specifically, the fragment can access the Activity instance with getActivity() and easily perform tasks such as find a view in the activity layout

提交回复
热议问题