IllegalStateException: Fragment already added in the tabhost fragment

后端 未结 11 1182
暗喜
暗喜 2020-12-04 14:07
FATAL EXCEPTION: main
Process: com.example.loan, PID: 24169
java.lang.IllegalStateException: Fragment already added: FormFragment{428f10c8 #1 id=0x7f050055 form}
            


        
11条回答
  •  天涯浪人
    2020-12-04 14:55

    This happens when we try to add same fragment or DialogFragment twice before dismissing,

    just call

    if(mFragment.isAdded())
    {
         return; //or return false/true, based on where you are calling from
    }
    

    Having said that, I don't see any reason why to remove old fragment and add the same fragment again since we can update the UI/data by simply passing parameters to the method inside the fragment

提交回复
热议问题