java.lang.IllegalStateException: Fragment no longer exists for key f1: index 3

后端 未结 8 674
一整个雨季
一整个雨季 2020-12-24 10:43

I want to understand this exception in order to implement a proper fix.

There\'s a ViewPager and it uses a FragmentStatePagerAdapter to instantiate 2 fragments via g

8条回答
  •  清酒与你
    2020-12-24 10:55

    very good ! Since is repeat pager.setAdapter(adapter); when call restoreState cause exception:

    Fragment no longer exists for key f0: index 0
    

    we can Release Fragment RootView

        public void onDestroyView() {
        super.onDestroyView();
        if (isRecyclerRootViewAlways()) {
            mRootView = null;//<--
        }
        mMyFragmentLifecycle.onFragmentDestroyView(this);
    }
    

提交回复
热议问题