FragmentPagerAdapter - How to handle Orientation Changes?
Yes like you said FragmentManager handles fragments after orientation change so getItem
in adapter is not called. But you can override method instantiateItem()
which is called even after orientation change and cast Object to Fragment and save it in your array.
@Override
public Object instantiateItem(ViewGroup container, int position) {
DataFragment fragment = (DataFragment) super.instantiateItem(container, position);
fragments[position] = fragment;
return fragment;
}