I am trying to construct an application where you can scroll through objects with a ViewPager. The ViewPager holds Fragments, support library due to SDK 9 restriction. The fragments are constructed from data in a bean-object.
When I leave the active view (with a transaction.replace) to another fragment (and returns) the page I'm on and 1-2 to the left and the right becomes blank- nothing from the xml is shown and the background of the ViewPager-xml-element is shown. When scrolling x pages the content returns to the pages (not all of them, you need to scroll around more for that). When I enter and leave a PreferenceActivity, I do not get this error.
What is causing this behaviour and how can I fix it?
My app looks like this:
1 FragmentActivity that has a FrameLayout. 2 fragments that replaces each other when called. Inside one of the fragments, browser, is some buttons and a ViewPager. The ViewPager has a (Fixed 1)FragmentStateChangeAdapter. If this is changed to FragmentChangeAdapter there is no difference.
The activity has a list of beans used in the ViewPager and a ListView in the other fragment, Search.
I've tried some suggestions without result:
ViewPager + FragmentStatePagerAdapter + orientation change
A bug in (and a fix for) the way FragmentStatePagerAdapter handles fragment restoration
I can supply code but this feels like a theory question, maybe in regard to saved states etc.