无法使用导航组件从嵌套图片段移动到主图片段

5ssjco0h  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(202)

我在主导航图中使用嵌套片段作为底部导航视图,但当尝试从嵌套图中的片段导航到主导航图中的登录片段时,控制器会将我重定向到homefragment,homefragment是嵌套图的startdestination
这是我的导航图xml

<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/nav_main"
    app:startDestination="@id/splashFragment">

    <fragment
        android:id="@+id/splashFragment"
        android:name="package.splash.SplashFragment"
        android:label="fragment_splash"
        tools:layout="@layout/fragment_splash">
        <action
            android:id="@+id/actionGoToHomeFromSplash"
            app:destination="@id/nav_home"
            app:launchSingleTop="true"
            app:popUpTo="@id/splashFragment"
            app:popUpToInclusive="true" />
        <action
            android:id="@+id/actionGoToLogin"
            app:destination="@id/loginFragment"
            app:launchSingleTop="true"
            app:popUpTo="@id/splashFragment"
            app:popUpToInclusive="true" />
    </fragment>
    <fragment
        android:id="@+id/loginFragment"
        android:name="package.signinup.LoginFragment"
        android:label="fragment_login"
        tools:layout="@layout/fragment_login">
        <action
            android:id="@+id/actionGoToHomeFromLogin"
            app:destination="@id/nav_home"
            app:launchSingleTop="true"
            app:popUpTo="@id/loginFragment"
            app:popUpToInclusive="true" />
    </fragment>

    <navigation
        android:id="@+id/nav_home"
        app:startDestination="@id/homeFragment">

        <fragment
            android:id="@+id/homeFragment"
            android:name="package.main.HomeFragment"
            android:label="fragment_home"

            tools:layout="@layout/fragment_home" />
        <fragment
            android:id="@+id/ordersFragment"
            android:name="package.main.OrdersFragment"
            android:label="fragment_orders"
            tools:layout="@layout/fragment_orders" />
        <fragment
            android:id="@+id/settingFragment"
            android:name="package.main.SettingFragment"
            android:label="fragment_setting"
            tools:layout="@layout/fragment_setting">
            <action
                android:id="@+id/actionGoToLoginFromSetting"
                app:destination="@id/loginFragment"
                 />
        </fragment>
        <action
            android:id="@+id/actionGoToLoginFromNavChild"
            app:destination="@id/loginFragment"

            />
    </navigation>
</navigation>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题