MikkoP
MikkoP

Reputation: 5092

Accessing Fragment objects from parent Activity

I have an ActionBarActivity that has a ViewPager with two Fragments and tabs created with ActionBar from the support library. My ActionBarActivity has also two buttons: cancel and save. When the save button is pressed, I need to get data from both of my Fragments. How do I do this? This data is stored fetched from the layout and stored in local variables in the Fragments.

Upvotes: 1

Views: 618

Answers (1)

Alexey A.
Alexey A.

Reputation: 1419

You should be able get access to your fragments by use of FragmentManager by id or tag. getFragmentManager().findFragmentById() or getFragmentManager().findFragmentByTag()

Upvotes: 1

Related Questions