gpt4 book ai didi

android - 杀死导航 Controller 中的 fragment

转载 作者:太空狗 更新时间:2023-10-29 16:25:35 25 4
gpt4 key购买 nike

我的fragment流程是这样的

Main -> A -> B -> C ->A

在 fragment c中,它有一个提交按钮,它将返回到A。当我按下 A 中的后退按钮时,我希望它返回 Main。但它返回到 fragment c。

在 fragment C中,我使用这个

 findNavController().navigate(R.id.action_c_to_a)

nav_graph.xml

 <fragment
android:id="@+id/fragmentC"
android:name="xxx"
android:label="xxx">
<action
app:launchSingleTop="true"
app:popUpTo="@+id/fragmentA"
app:popUpToInclusive="true"
android:id="@+id/action_c_to_a"
app:destination="@id/fragmentA" />
</fragment>

最佳答案

为什么不弹出 fragment A?您可以只调用 findNavController().popBackStack(R.id.fragmentA, false) 而不是通过操作进行导航。

关于android - 杀死导航 Controller 中的 fragment ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56748636/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com