我的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/