Delete one specific fragment from the Android backstack

前端 未结 4 1664
离开以前
离开以前 2020-12-30 00:46

For a android tablet application I use 2 fragments. One on the left side on the screen and one on the right side. When you click on a button at the right fragment, another f

4条回答
  •  一向
    一向 (楼主)
    2020-12-30 01:19

    You can create your own fragment manager/observer. It will be just a simple list or map inside. Track them using tag or simply class name (getClass). This way you'll be able to avoid new fragment creation and reuse cached one, thus controlling your memory consumption. You will also be able to manipulate fragments the way you want (override onBackPressed and push which ever fragment you like), instead of using only the way Google says it should/can be done.

提交回复
热议问题