How to access parent Activity View in Fragment

I have an ActionBarActivity and fragment. I am using FragmentPagerAdapter that provides fragment to my app. My question How can I access parent Activity View in Fragment ??


Solution 1:

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

Solution 2:

In Kotlin it is very easy to access parent Activity View in Fragment

activity!!.textview.setText("String")