I have a litle doubt.
I have an activity that have 3 fragment inside. I need to restart the state of one of these fragments. Restart only one.
You can access another Fragment by its tag: // find your fragment YourFragment f = (YourFragment) getSupportFragmentManager(). findFragmentByTag("yourFragTag"); // update the list view f. updateListView();
OnPageChangeListener is the correct way to go, but you will need to refactor your adapter a bit in order to keep a reference to each Fragment contained in the FragmentPagerAdapter. Then, instead of creating a new Fragment, use the one contained in the adapter: mViewPager. addOnPageChangeListener(new ViewPager.
Old, but may be useful to someone else. To refresh the fragment, you need to detach the fragment and reattach it
Fragment frg = null;
frg = getFragmentManager().findFragmentByTag("Your_Fragment_TAG");
final FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.detach(frg);
ft.attach(frg);
ft.commit();
Your_Fragment_TAG is the name you gave your fragment when you created it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With