在dialogfragment&带有导航组件的碎片

发布于 2025-01-21 20:37:03 字数 1316 浏览 0 评论 0原文

在上面的导航流中,我在从对话框导航到对话框1堆栈时,我正面临问题 - 因此从对话框1点击设备返回按钮,然后返回对话框3,而不是转到fragment

     <fragment
        android:id="@+id/fragment1"
        android:name="fragment"
        tools:layout="@layout/fragment1" />

     <dialog
        android:id="dialog1"
        android:name="dialog1"
        tools:layout="@layout/dialog1" />

     <dialog
        android:id="@+id/dialog2"
        android:name="dialog2"
        tools:layout="@layout/dialog2" />

    <dialog
        android:id="@+id/dialog3"
        android:name="dialog3"
        tools:layout="@layout/dialog3">

        <action
            android:id="@+id/actionToDialog1"
            app:destination="@id/dialog1"
            app:launchSingleTop="true"
            app:popUpTo="@id/dialog1"
            app:popUpToInclusive="true" />

    </dialog>

在设备返回按钮上,我在下面的代码下方

navController.navigate(R.id.actionToDialog1);

,导航正常工作,但是一旦您登陆对话框1堆栈未清除,它应该转到fragment而是去。到对话框3

Navigation Flow

In the above navigation flow, I am facing an issue while navigating from Dialog 3 to Dialog 1 stack is not getting cleared --- so when I tap the device back button from Dialog 1 then takes back to Dialog 3 instead of going to Fragment.

     <fragment
        android:id="@+id/fragment1"
        android:name="fragment"
        tools:layout="@layout/fragment1" />

     <dialog
        android:id="dialog1"
        android:name="dialog1"
        tools:layout="@layout/dialog1" />

     <dialog
        android:id="@+id/dialog2"
        android:name="dialog2"
        tools:layout="@layout/dialog2" />

    <dialog
        android:id="@+id/dialog3"
        android:name="dialog3"
        tools:layout="@layout/dialog3">

        <action
            android:id="@+id/actionToDialog1"
            app:destination="@id/dialog1"
            app:launchSingleTop="true"
            app:popUpTo="@id/dialog1"
            app:popUpToInclusive="true" />

    </dialog>

On Device Back Button Tap I am having below code

navController.navigate(R.id.actionToDialog1);

FYI, navigation works fine, but once you land on Dialog 1 stack is not getting cleared and it should go to Fragment instead goes to Dialog 3

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文