Возможно ли иметь динамическое назначение в Nested Navigation Graph Android? - PullRequest
0 голосов
/ 14 сентября 2018

Я реализовал вложенный граф в графе навигации, в котором есть 2 графика.На первом графике 3 фрагмента, а на втором - 2 фрагмента.График 2 включен в график 1. Я хочу перейти к (график 1, шаг 1) к (график 2, шаг 2).Мы не можем определить действие между двумя вложенными фрагментами.Так есть ли способ, которым мы можем назначить динамический пункт назначения для навигации?

enter image description here

График 1

<?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/mobile_navigation"
    app:startDestination="@id/dashboardFragment">
    <fragment
        android:id="@+id/dashboardFragment"
        android:name="com.navigationgraphexample.fragments.DashboardFragment"
        android:label="fragment_dashboard"
        tools:layout="@layout/fragment_dashboard" >
        <action
            android:id="@+id/action_dashboardFragment_to_stepOneFragment2"
            app:destination="@id/stepOneFragment" />
        <action
            android:id="@+id/action_dashboardFragment_to_sub_nav"
            app:destination="@id/sub_nav" />

    </fragment>
    <fragment
        android:id="@+id/stepOneFragment"
        android:name="com.navigationgraphexample.fragments.StepOneFragment"
        android:label="fragment_step_one"
        tools:layout="@layout/fragment_step_one">
        <action
            android:id="@+id/action_stepOneFragment_to_stepTwoFragment"
            app:destination="@id/stepTwoFragment" />
    </fragment>
    <fragment
        android:id="@+id/stepTwoFragment"
        android:name="com.navigationgraphexample.fragments.StepTwoFragment"
        android:label="fragment_step_two"
        tools:layout="@layout/fragment_step_two" />
    <fragment
        android:id="@+id/notificationFragment"
        android:name="com.navigationgraphexample.fragments.NotificationFragment"
        android:label="fragment_notification"
        tools:layout="@layout/fragment_notification" >
        <deepLink
            android:id="@+id/deepLink"
            app:uri="myapp.com/{myargs}"
            />
        <argument android:name="myargs"
            app:argType="integer"
            android:defaultValue="1" />
    </fragment>
    <include app:graph="@navigation/sub_nav" />
</navigation>

График 2

<?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/sub_nav"
    app:startDestination="@id/createNewTaskFragment">

    <fragment
        android:id="@+id/listFragment"
        android:name="com.navigationgraphexample.fragments.ListFragment"
        android:label="fragment_list"
        tools:layout="@layout/fragment_list" />
    <fragment
        android:id="@+id/createNewTaskFragment"
        android:name="com.navigationgraphexample.fragments.CreateNewTaskFragment"
        android:label="fragment_create_new_task"
        tools:layout="@layout/fragment_create_new_task" >
        <action
            android:id="@+id/action_createNewTaskFragment_to_listFragment"
            app:destination="@id/listFragment" />
    </fragment>
</navigation>

Я проверил это решение, но оно не для вложенного графа!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...