How to properly handle screen rotation with a ViewPager and nested fragments?

前端 未结 6 683
执念已碎
执念已碎 2021-01-31 03:42

I\'ve got this activity, which holds a fragment. This fragment layout consists of a view pager with several fragments (two, actually).

When the view pager is created, it

6条回答
  •  悲哀的现实
    2021-01-31 04:15

    With reference to simekadam's solution, mFragments isn't being populated in instantiateItem and needs mFragments.put(position, fragment); inside or you'll end up with this error: Trying to remove fragment from view gives me NullPointerException on mNextAnim.

提交回复
热议问题