How to destroy Fragment?

前端 未结 5 1455
北恋
北恋 2020-12-13 17:21

I have one Activity. The Activity has two Fragments. Fragment A is Menu. Fragment B is Detail.

I try to Make other Fragment C

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 18:01

    If you don't remove manually these fragments, they are still attached to the activity. Your activity is not destroyed so these fragments are too. To remove (so destroy) these fragments, you can call:

    fragmentTransaction.remove(yourfragment).commit()
    

    Hope it helps to you

提交回复
热议问题