[英]How to avoid adding a fragment to the backstack if it already exists using Navigation Architecture Component?
I am using navigation component so I'm not using a FragmentManager.我正在使用导航组件,所以我没有使用 FragmentManager。 Let's say I have fragments A, B.
假设我有片段 A、B。
If user navigates A -> B -> A -> B and then presses the back button I want the backstack to just be A instead of A -> B -> A. In other words don't add a Fragment if it already exists in the backstack.如果用户导航 A -> B -> A -> B 然后按下后退按钮,我希望 backstack 只是 A 而不是 A -> B -> A。换句话说,如果片段已经存在,则不要添加它在后台。 Is this possible without using FragmentManager?
这可能不使用 FragmentManager 吗?
Yes you need to use setPopUpTo
是的,您需要使用
setPopUpTo
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.