NavGraph

public class NavGraph extends NavDestination

Object
   ↳ NavDestination
     ↳ NavGraph

NavGraph is a collection of NavDestination nodes fetchable by ID.

A NavGraph serves as a 'virtual' destination: while the NavGraph itself will not appear on the back stack, navigating to the NavGraph will cause the starting destination to be added to the back stack.

Construct a new NavGraph. This NavGraph is not valid until you add a destination and set the starting destination.

Summary

Nested types

NavGraph.Companion

Public fields

final @NonNull SparseArrayCompat<@NonNull NavDestination>
final @NonNull String
final int

The starting destination id for this NavGraph.

final @Nullable String

The route for the starting destination for this NavGraph.

Public constructors

NavGraph(@NonNull Navigator<@NonNull NavGraph> navGraphNavigator)

Public methods

final void

Add all destinations from another collection to this one.

final void

Adds a destination to this NavGraph.

final void

Adds multiple destinations to this NavGraph.

final void

Adds multiple destinations to this NavGraph.

final void

Clear all destinations from this navigation graph.

boolean
final @Nullable NavDestination
findNode(@IdRes int resId)

Finds a destination in the collection by ID.

final @Nullable NavDestination

Finds a destination in the collection by route.

final @IdRes int

This method is deprecated. Use getStartDestinationId instead.

int
final @NonNull Iterator<@NonNull NavDestination>
void

Called when inflating a destination from a resource.

final void

Remove a given destination from this NavGraph

final void
setStartDestination(int startDestId)

Sets the starting destination for this NavGraph.

final void

Sets the starting destination for this NavGraph.

@NonNull String

Extension functions

final boolean
NavGraphKt.contains(@NonNull NavGraph receiver, @IdRes int id)

Returns true if a destination with id is found in this navigation graph.

final boolean

Returns true if a destination with route is found in this navigation graph.

final @NonNull NavDestination
NavGraphKt.get(@NonNull NavGraph receiver, @IdRes int id)

Returns the destination with id.

final @NonNull NavDestination