android - 杀死导航 Controller 中的 fragment

标签 android kotlin navigation fragment navigationcontroller

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

相关文章:

android - 在 android 的数据库中存储用户组的最佳想法

magento - 如何获取所有类别和子类别?

android - 横向模式下的软键盘不会在 Android 模拟器中弹出

android - 在我的 Android 应用程序中,如何将图像从它们的位置移开?

java - Instagram redirect_uri 的自定义模式

multithreading - 从 HashMap 检索时出现 NPE,即使 containsKey() 在多线程环境中返回 true

spring - 如何检查 Mono 是否为空?

android-studio - 在android studio中以C代码输入JNI函数时的art_sigsegv_fault

java - 如何将大个人资料图片添加到我的抽屉导航中?

navigation - 如何在SwiftUI Apple Watch App中从一个屏幕导航到另一个屏幕