导航Jetpack如何导航到原始片段

时间:2019-11-13 15:39:00

标签: android navigation android-jetpack android-jetpack-navigation

我有3个片段:nav_home-> draw_request-> draw_confirmation

一切正常。除了第一个循环之后,nav_home直接进入draw_confirmation。所以这是顺序: nav_home-> draw_request-> draw_confirmation-> nav_home-> draw_confirmation

我想要的是: nav_home-> draw_request-> draw_confirmation-> nav_home-> draw_request .....

enter image description here

<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/navigation_main_graph"
    app:startDestination="@id/nav_home">
    <fragment
        android:id="@+id/nav_home"
        android:name="com.enova.cashnet.ui.main.home.HomeFragment"
        tools:layout="@layout/fragment_main_home">
        <action
            android:id="@+id/action_nav_home_to_draw_request"
            app:destination="@id/draw_request" />
    </fragment>

    <fragment
        android:id="@+id/draw_request"
        android:name="com.enova.cashnet.ui.draw.request.DrawRequestFragment"
        tools:layout="@layout/fragment_draw_request">
        <action
            android:id="@+id/action_draw_request_to_draw_confirmation"
            app:destination="@id/draw_confirmation" />
    </fragment>

    <fragment
        android:id="@+id/draw_confirmation"
        android:name="com.enova.cashnet.ui.draw.confirmation.DrawConfirmationFragment"
        tools:layout="@layout/fragment_draw_confirmation">
        <argument
            android:name="drawRequestResponseBody"
            app:argType="com.enova.cashnet.model.DrawRequestResponseBody" />
         <action
            android:id="@+id/action_draw_confirmation_to_nav_home"
            app:destination="@id/nav_home"
            app:popUpTo="@+id/nav_home"
            app:popUpToInclusive="true"/>
    </fragment>
</navigation>

打开draw_request的代码:

private fun onAccountSummaryDrawTapped() {
        accountSummaryLOCCard?.btn_cta?.findNavController()?.navigate(R.id.action_nav_home_to_draw_request)
    }

0 个答案:

没有答案