PopBackStack but keep the first fragment in android

前端 未结 10 568
[愿得一人]
[愿得一人] 2020-12-10 12:31

I am working on fragment transaction, and the backstack is like this:

fragA => fragB => fragC => fragD

I would like to return to f

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 13:02

    The backstack contains records about transactions, not fragments itself. So you should not add first transaction's record (null -> fragA) to backstack. And all other transaction's record should be added to backstack. In this case, then you preformpopBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); android removed all fragments except fragA, because there isn't any records about how fragA was added.

提交回复
热议问题