onCreateView not called with Fragment in ViewPager
The vital part seems to have been the FragmentPagerAdapter
(which I didn't include). Debugging shows that getItem()
isn't called when the activity is re-created. The Fragments are re-created by other means. Which meant that my implementation of FragmentPagerAdapter
had wrong references to the fragments in the FragmentManager
.
So instead, when I need to lookup a fragment I use findFragmentByTag()
(on the FragmentManager
) using the makeFragmentName()
to get the appropriate tag name. That's method used by the FragmentPagerAdapter
when the fragment is added. Not sure whether this is a safe approach or not though.