Got exception: fragment already active

前端 未结 8 1652
攒了一身酷
攒了一身酷 2021-01-30 12:49

I have a fragment;

MyFragment myFrag = new MyFragment();

I put bundle data to this fragment:

         


        
8条回答
  •  隐瞒了意图╮
    2021-01-30 13:29

    remove() change fragment status to de-actiive. In your case, you just didn't call commit() after remove(..).

    fragmentTransaction.remove(activeFragment);
    

    You would do commit() after remove(), too.

    fragmentTransaction.remove(activeFragment).commit();
    

提交回复
热议问题