FragmentStatePagerAdapter with ChildFragmentManager - FragmentManagerImpl.getFragment results in NullPointerException

前端 未结 4 1915
生来不讨喜
生来不讨喜 2020-12-02 23:28

EDIT 2

I now managed to get rid of the error with using the trick from here https://code.google.com/p/android/issues/detail?id=42601#c10 so that\'s

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 23:56

    On my side, I was keeping a reference to the ViewPager fragments in a containing fragment and was using onSaveInstanceState to store their states. I think the NPE occurred because this was colliding with the ViewPager own mechanism to restore the fragments. What I did, change my architecture from a ViewPager to fragment transactions I manage myself. (ViewPager was not an appropriate solution for my case)

提交回复
热议问题