Android ViewPager orientation change

后端 未结 1 1695
一整个雨季
一整个雨季 2021-01-24 08:26

I have read from @antonyt\'s answer to this StackOverflow question that FragmentPagerAdapter will try to reuse an existing fragment found by

相关标签:
1条回答
  • 2021-01-24 08:54

    All fragments which not set setRetainInstance(true) are destroyed on orientation change. After orientation changed all fragments are recreated and reattach by fragment manager (so fragment goes throught entire lifecycle).

    All fragment attached by ViewPager are added to fragment manager with special tag. ViewPager try to reuse fragment recreated after orientation changed (by searching for tag in fragment manager). If such fragment don't exist then FragmentPagerAdapter.getItem(int) is called to create new fragment.

    0 讨论(0)
提交回复
热议问题