11

I have a single activity application with 3 modules - app, list & detail. My activity is in app module, it's hosting the only NavHostFragment. All modules have their own navigation graphs. detail's starting point requires a long parameter. app's graph is parenting other graphs:

<?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"
    android:id="@+id/nav_main"
    app:startDestination="@id/nav_list">

    <include app:graph="@navigation/nav_list" />
    <include app:graph="@navigation/nav_detail" />
</navigation>

But by default it's disabled to add actions to included graphs on editor:

ss1

I can add a global action in xml file which then shows up in editor:

<?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"
    android:id="@+id/nav_main"
    app:startDestination="@id/nav_list">

    <include app:graph="@navigation/nav_list" />
    <include app:graph="@navigation/nav_detail" />
    
    <action
        android:id="@+id/action_global_detailFragment"
        app:destination="@id/nav_detail" />
</navigation>

I don't want to use global actions but instead add proper actions which will encapsulate navigation pattern. Nested graphs already contain their navigation logic and only may need input for entry point. I'm not sure if this is not supported and I'm missing something or else why not ? What's the way to navigate between two or more included graphs ?

Mark
  • 7,446
  • 5
  • 55
  • 75
Mel
  • 1,730
  • 17
  • 33

1 Answers1

0

You have to set android:idto your included graphs, otherwise you cannot add actions.

martirius
  • 46
  • 6