pop specific fragment from stack and remove others

前端 未结 5 1072
情话喂你
情话喂你 2020-12-30 07:32

how I can pop specific fragment from stack and remove others from a fragment? for example these are my fragments and I\'m in E right know.

A-> B -> C -> D ->E

<
5条回答
  •  死守一世寂寞
    2020-12-30 08:19

    tldr: try using fragmentManager instead of supportFragmentManager if the code doesn't work

    solution: fragmentManager.popBackStackImmediate(tagName, 0)

    I know it's an old question but after spending a few hours on this, I wasn't able to get close to the desired result.

    I was using supportFragmentManager and the code was:

    supportFragmentManager.popBackStackImmediate(tagName, 0)

    but it wasn't working as intended neither according to what was written in the documentation. Just as a fluke I thought about using the fragmentManager instead of the supportFragmentManager and voila, it worked!

    So for anyone stuck on this, maybe give this a try.

提交回复
热议问题