I a using ViewPager
with FragmentStatePageAdapter
on my screen I have 5 pages which has lots of images and views. Currently I have mViewPager.setOffscreenPageLimit(1);
so only current, previous and next will be in memory and other 2 will be destroyed. But for that destroyed fragments I want to make use of saveState()
and restoreState()
of the adapter to maintain its state so when I come back to that screen it will anyways go to onCreateView()
of that fragment what will maintain state also.
Having mViewPager.setOffscreenPageLimit(4);
is not a good option as it has memory issues.
I searched a lot but I didn't get any sample which make use of this 2 functions to maintain and restore state.
Can someone help me out to proceed.