Keeping PageView Fragment's View from disposal

159 views Asked by At

I have an Android Application implementing a PageView with Tabs found here: https://github.com/sbpc/ajavacc The PageView loads its Fragments and displays everything properly; but occasionally the individual Fragments become disposed. Is there a way to either store the Fragment's state, prevent the pages from being disposed; or do I need to save the values which construct each page to a file?

1

There are 1 answers

0
Yash Sampat On BEST ANSWER

The class MainPagerAdapter is already using FragmentPagerAdapter which keeps the created Fragments in memory. You can go one step further and add the method setRetainInstance(true) to each Fragment in the ViewPager. This should work. You can read more about this here.