IllegalStateException: is not currently in the FragmentManager

后端 未结 12 2139
予麋鹿
予麋鹿 2021-01-31 08:40

I know it sounds like a duplicate of FragmentStatePagerAdapter IllegalStateException: is not currently in the FragmentManager but his solution isn\'t relevan

12条回答
  •  南方客
    南方客 (楼主)
    2021-01-31 09:06

    Use the following

    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.add(f, key);
    

    instead of

    mFragmentManager.putFragment(state, key, f);
    

    and pass the bundle explicitly..

    For reference,

    http://developer.android.com/reference/android/app/FragmentTransaction.html#add%28android.app.Fragment,%20java.lang.String%29

提交回复
热议问题