Skip to content

Instantly share code, notes, and snippets.

@huan-nguyen
Last active July 6, 2020 03:09
Show Gist options
  • Select an option

  • Save huan-nguyen/85b1cf492d2932384fcea4815ae3b0a4 to your computer and use it in GitHub Desktop.

Select an option

Save huan-nguyen/85b1cf492d2932384fcea4815ae3b0a4 to your computer and use it in GitHub Desktop.
Examples of how destinations are defined in a NavGraph
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
app:startDestination="@id/greatFragment">
<!-- Create a fragment destination -->
<fragment
android:id="@+id/myGreatFragment"
android:name="com.example.MyGreatFragment"
android:label="myGreatFragment"
tools:layout="@layout/great_fragment" >
</fragment>
<!-- Create an activity destination -->
<activity
android:id="@+id/myGreatActivity"
android:name="com.example.MyGreatActivity"
android:label="myGreatActivity"
tools:layout="@layout/great_activity" />
<!-- Create a dialog fragment destination -->
<dialog
android:id="@+id/myGreatDialogFragment"
android:name="com.example.MyGreatDialogFragment"
android:label="myGreatDialogFragment"
tools:layout="@layout/great_dialog" />
<!-- Create a "nav graph" destination (which allows nested graph navigation) -->
<navigation android:id="@+id/myGreatGraph"
android:label="myGreatGraph"
app:startDestination="@id/dest1Fragment">
<fragment
android:id="@+id/dest1Fragment"
android:name="com.example.Dest1Fragment"
android:label="dest1Fragment"
tools:layout="@layout/dest_1" >
</fragment>
<fragment
android:id="@+id/dest2Fragment"
android:name="com.example.Dest2Fragment"
android:label="dest2Fragment"
tools:layout="@layout/dest_2" >
</fragment>
</navigation>
</navigation>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment