Skip to content Skip to sidebar Skip to footer

Fragment Doesn't Refresh Content After Returning From Back Stack

I have a ZooFragment which contains a ViewPager. This ViewPager has three children: LionFragment, LeopardFragment, and TigerFragment, each of these children can request transactio

Solution 1:

Please do not replace the fragments in the ViewPager, just show (using transaction) in any other contained in the same layout as that of ViewPager and that container should be a FrameLayout. Also device a mechanism to know when and what fragment comes into view. Then request for a fresh data from a utility that responds to update your fragment. I do not think onDestroyed will be called in case of all the fragments in the ViewPager. Fragments in the ViewPager are fixed, so should there contents will not go till the application manager wants to destroy it.Instead of trying to replace the fragments in the adapter, try to give a different set of fragments and notifyDataSet changed, or take the advantage of FrameLayout to show another fragment over the view pager tab's current fragment.

There is my solution that works:

Swipe Gesture applied at Fragment level along with ViewPager with it's default swipe disabled

Post a Comment for "Fragment Doesn't Refresh Content After Returning From Back Stack"