question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[NavigationAdvancedSample] How to use root graph and global action?

See original GitHub issue

I am trying to extend the [NavigationAdvancedSample] repo with the global action/destination like this: `app_navigation.xml <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/app_navigation" app:startDestination="@id/home">

<include app:graph="@navigation/home" />

<include app:graph="@navigation/list" />

<include app:graph="@navigation/form" />

<action android:id="@+id/action_open_detail"
    app:destination="@id/nav_detail"/>

<fragment android:id="@+id/nav_detail"
    android:name="com.example.android.navigationadvancedsample.detail.Detail"
    android:label="Detail"
    tools:layout="@layout/fragment_detail"/>

</navigation>`

I’m looking for the solution to navigate to nav_detail by action action_open_detail from home/list or form. But It’s doesn’t working. Have any suggest to use this functions like up with [NavigationAdvancedSample]?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

1reaction
ildar2commented, Nov 24, 2020

@yusufceylan


<navigation1 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/main">

    <action
        android:id="@+id/action_auth"
        app:destination="@id/auth_navigation" />

    <action
        android:id="@+id/action_rename"
        app:destination="@id/tab_products" />

    <fragment
        android:id="@+id/main"
        android:name="ui.main.MainFragment" <-- this fragment contains bottom tab graphs -->
        tools:layout="@layout/fragment_main" />

    <dialog
        android:id="@+id/auth_needed"
        android:name="ui.auth.AuthNeededDialog"
        tools:layout="@layout/include_auth_needed" />

    <dialog
        android:id="@+id/share_schedule"
        android:name="ui.main.products.detail.ShareDialog"
        tools:layout="@layout/dialog_credit_schedule_share" />

    <include app:graph="@navigation/auth_navigation" />

 </navigation>

0reactions
sinhpn92commented, Nov 24, 2020

@yusufceylan That’s to make include more usefull with me to reuse action and fragment from global destination instead of define on each navigation. It’s duplicate code. 😦(

Read more comments on GitHub >

github_iconTop Results From Across the Web

Menu & Global Actions - Getting Started With ... - YouTube
In this part, we will connect an options menu to our navigation graph so we can navigate to destinations via menu items, ...
Read more >
Global actions - Android Developers
You can use a global action to create a common action that multiple ... From the Graph Editor, click on a destination to...
Read more >
Android Jetpack Navigation, BottomNavigationView with ...
You can handle back action using popUpTo property in action tag. ... the navigation xml graph into one for each bottom navigation item, ......
Read more >
Support multiple back stacks for Bottom tab navigation
Check out NavigationExtensions.kt in the NavigationAdvancedSample. ... back stacks using a single NavHostFragment / navigation graph / FragmentManager, yes.
Read more >
Trying to understand the appeal of navigation components
You can still put those fragments in the nav graph. ... You can create Global Actions to navigate to the Profile graph.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found