# NavigationUI

Artifact: [androidx.navigation:navigation-ui](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/ui/NavigationUI.kt+class:androidx.navigation.ui.NavigationUI) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

*** ** * ** ***


```
public static class NavigationUI
```

<br />

*** ** * ** ***

Class which hooks up elements typically in the 'chrome' of your application such as global navigation patterns like a navigation drawer or bottom nav bar with your `https://developer.android.com/reference/androidx/navigation/NavController`.

## Summary

| ### Public fields |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/NavigationUI` | `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#INSTANCE()` |

| ### Public methods |
|---|---|
| `static final boolean` | `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#navigateUp(androidx.navigation.NavController,androidx.navigation.ui.AppBarConfiguration)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration configuration )` Handles the Up button by delegating its behavior to the given NavController. |
| `static final boolean` | `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#navigateUp(androidx.navigation.NavController,androidx.customview.widget.Openable)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, https://developer.android.com/reference/androidx/customview/widget/Openable openableLayout)` Handles the Up button by delegating its behavior to the given NavController. |
| `static final boolean` | `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#onNavDestinationSelected(android.view.MenuItem,androidx.navigation.NavController)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/MenuItem.html item, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController )` Attempt to navigate to the `https://developer.android.com/reference/androidx/navigation/NavDestination` associated with the given MenuItem. |
| `static final boolean` | `@https://developer.android.com/reference/androidx/navigation/ui/NavigationUiSaveStateControl https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#onNavDestinationSelected(android.view.MenuItem,androidx.navigation.NavController,kotlin.Boolean)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/MenuItem.html item, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, boolean saveState )` Attempt to navigate to the `https://developer.android.com/reference/androidx/navigation/NavDestination` associated with the given MenuItem. |
| `static final void` | `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#setupActionBarWithNavController(androidx.appcompat.app.AppCompatActivity,androidx.navigation.NavController,androidx.navigation.ui.AppBarConfiguration)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity activity, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration configuration )` Sets up the ActionBar returned by `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity#getSupportActionBar()` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |
| `static final void` | `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#setupActionBarWithNavController(androidx.appcompat.app.AppCompatActivity,androidx.navigation.NavController,androidx.customview.widget.Openable)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity activity, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, https://developer.android.com/reference/androidx/customview/widget/Openable openableLayout )` Sets up the ActionBar returned by `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity#getSupportActionBar()` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |
| `static final void` | `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#setupWithNavController(com.google.android.material.navigation.NavigationBarView,androidx.navigation.NavController)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.html navigationBarView, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController )` Sets up a `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.html` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |
| `static final void` | `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#setupWithNavController(com.google.android.material.navigation.NavigationView,androidx.navigation.NavController)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/navigation/NavigationView.html navigationView, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController )` Sets up a `https://developer.android.com/reference/com/google/android/material/navigation/NavigationView.html` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |
| `static final void` | `@https://developer.android.com/reference/androidx/navigation/ui/NavigationUiSaveStateControl https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#setupWithNavController(com.google.android.material.navigation.NavigationBarView,androidx.navigation.NavController,kotlin.Boolean)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.html navigationBarView, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, boolean saveState )` Sets up a `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.html` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |
| `static final void` | `@https://developer.android.com/reference/androidx/navigation/ui/NavigationUiSaveStateControl https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#setupWithNavController(com.google.android.material.navigation.NavigationView,androidx.navigation.NavController,kotlin.Boolean)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/navigation/NavigationView.html navigationView, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, boolean saveState )` Sets up a `https://developer.android.com/reference/com/google/android/material/navigation/NavigationView.html` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |
| `static final void` | `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#setupWithNavController(androidx.appcompat.widget.Toolbar,androidx.navigation.NavController,androidx.navigation.ui.AppBarConfiguration)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration configuration )` Sets up a `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |
| `static final void` | `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#setupWithNavController(androidx.appcompat.widget.Toolbar,androidx.navigation.NavController,androidx.customview.widget.Openable)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, https://developer.android.com/reference/androidx/customview/widget/Openable openableLayout )` Sets up a `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |
| `static final void` | `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#setupWithNavController(com.google.android.material.appbar.CollapsingToolbarLayout,androidx.appcompat.widget.Toolbar,androidx.navigation.NavController,androidx.navigation.ui.AppBarConfiguration)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html collapsingToolbarLayout, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration configuration )` Sets up a `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html` and `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |
| `static final void` | `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#setupWithNavController(com.google.android.material.appbar.CollapsingToolbarLayout,androidx.appcompat.widget.Toolbar,androidx.navigation.NavController,androidx.customview.widget.Openable)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html collapsingToolbarLayout, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, https://developer.android.com/reference/androidx/customview/widget/Openable openableLayout )` Sets up a `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html` and `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |

## Public fields

### INSTANCE

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
public static @NonNull NavigationUI INSTANCE
```

## Public methods

### navigateUp

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

```
public static final boolean navigateUp(
    @NonNull NavController navController,
    @NonNull AppBarConfiguration configuration
)
```

Handles the Up button by delegating its behavior to the given NavController. This is an alternative to using `https://developer.android.com/reference/androidx/navigation/NavController#navigateUp()` directly when the given `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration` needs to be considered when determining what should happen when the Up button is pressed.

In cases where no Up action is available, the `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration#fallbackOnNavigateUpListener()` will be called to provide additional control.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController that hosts your content. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration configuration` | Additional configuration options for determining what should happen when the Up button is pressed. |

| Returns |
|---|---|
| `boolean` | True if the `https://developer.android.com/reference/androidx/navigation/NavController` was able to navigate up. |

### navigateUp

Added in [2.3.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.3.0)

```
public static final boolean navigateUp(@NonNull NavController navController, Openable openableLayout)
```

Handles the Up button by delegating its behavior to the given NavController. This should generally be called from `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity#onSupportNavigateUp()`.

If you do not have a `https://developer.android.com/reference/androidx/customview/widget/Openable` layout, you should call `https://developer.android.com/reference/androidx/navigation/NavController#navigateUp()` directly.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController that hosts your content. |
| `https://developer.android.com/reference/androidx/customview/widget/Openable openableLayout` | The Openable layout that should be opened if you are on the topmost level of the app. |

| Returns |
|---|---|
| `boolean` | True if the `https://developer.android.com/reference/androidx/navigation/NavController` was able to navigate up. |

### onNavDestinationSelected

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

```
public static final boolean onNavDestinationSelected(
    @NonNull MenuItem item,
    @NonNull NavController navController
)
```

Attempt to navigate to the `https://developer.android.com/reference/androidx/navigation/NavDestination` associated with the given MenuItem. This MenuItem should have been added via one of the helper methods in this class.

Importantly, it assumes the `https://developer.android.com/reference/android/view/MenuItem.html#getItemId()` matches a valid `https://developer.android.com/reference/androidx/navigation/NavDestination#getAction(kotlin.Int)` or `https://developer.android.com/reference/androidx/navigation/NavDestination#id()` to be navigated to.

By default, the back stack will be popped back to the navigation graph's start destination. Menu items that have `android:menuCategory="secondary"` will not pop the back stack.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/MenuItem.html item` | The selected MenuItem. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController that hosts the destination. |

| Returns |
|---|---|
| `boolean` | True if the `https://developer.android.com/reference/androidx/navigation/NavController` was able to navigate to the destination associated with the given MenuItem. |

### onNavDestinationSelected

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
@NavigationUiSaveStateControl
public static final boolean onNavDestinationSelected(
    @NonNull MenuItem item,
    @NonNull NavController navController,
    boolean saveState
)
```

Attempt to navigate to the `https://developer.android.com/reference/androidx/navigation/NavDestination` associated with the given MenuItem. This MenuItem should have been added via one of the helper methods in this class.

Importantly, it assumes the `https://developer.android.com/reference/android/view/MenuItem.html#getItemId()` matches a valid `https://developer.android.com/reference/androidx/navigation/NavDestination#getAction(kotlin.Int)` or `https://developer.android.com/reference/androidx/navigation/NavDestination#id()` to be navigated to.

By default, the back stack will be popped back to the navigation graph's start destination. Menu items that have `android:menuCategory="secondary"` will not pop the back stack.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/MenuItem.html item` | The selected MenuItem. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController that hosts the destination. |
| `boolean saveState` | Whether the NavController should save the back stack state. This must always be `false`: leave this parameter off entirely to use the non-experimental version of this API, which saves the state by default. |

| Returns |
|---|---|
| `boolean` | True if the `https://developer.android.com/reference/androidx/navigation/NavController` was able to navigate to the destination associated with the given MenuItem. |

### setupActionBarWithNavController

Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.0.0)

```
public static final void setupActionBarWithNavController(
    @NonNull AppCompatActivity activity,
    @NonNull NavController navController,
    @NonNull AppBarConfiguration configuration
)
```

Sets up the ActionBar returned by `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity#getSupportActionBar()` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`.

By calling this method, the title in the action bar will automatically be updated when the destination changes (assuming there is a valid `https://developer.android.com/reference/androidx/navigation/NavDestination#label()`).

The `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration` you provide controls how the Navigation button is displayed. Call `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#navigateUp(androidx.navigation.NavController,androidx.customview.widget.Openable)` to handle the Up button.

Destinations that implement `https://developer.android.com/reference/androidx/navigation/FloatingWindow` will be ignored.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity activity` | The activity hosting the action bar that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController whose navigation actions will be reflected in the title of the action bar. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration configuration` | Additional configuration options for customizing the behavior of the ActionBar |

### setupActionBarWithNavController

Added in [2.3.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.3.0)

```
public static final void setupActionBarWithNavController(
    @NonNull AppCompatActivity activity,
    @NonNull NavController navController,
    Openable openableLayout
)
```

Sets up the ActionBar returned by `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity#getSupportActionBar()` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`.

By calling this method, the title in the action bar will automatically be updated when the destination changes (assuming there is a valid `https://developer.android.com/reference/androidx/navigation/NavDestination#label()`).

The start destination of your navigation graph is considered the only top level destination. On the start destination of your navigation graph, the ActionBar will show the drawer icon if the given Openable layout is non null. On all other destinations, the ActionBar will show the Up button. Call `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#navigateUp(androidx.navigation.NavController,androidx.customview.widget.Openable)` to handle the Up button.

Destinations that implement `https://developer.android.com/reference/androidx/navigation/FloatingWindow` will be ignored.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity activity` | The activity hosting the action bar that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController whose navigation actions will be reflected in the title of the action bar. |
| `https://developer.android.com/reference/androidx/customview/widget/Openable openableLayout` | The Openable layout that should be toggled from the home button |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#setupActionBarWithNavController(androidx.appcompat.app.AppCompatActivity,androidx.navigation.NavController,androidx.customview.widget.Openable)` |   |

### setupWithNavController

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
public static final void setupWithNavController(
    @NonNull NavigationBarView navigationBarView,
    @NonNull NavController navController
)
```

Sets up a `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.html` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. This will call `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#onNavDestinationSelected(android.view.MenuItem,androidx.navigation.NavController)` when a menu item is selected. The selected item in the NavigationBarView will automatically be updated when the destination changes.

Destinations that implement `https://developer.android.com/reference/androidx/navigation/FloatingWindow` will be ignored.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.html navigationBarView` | The NavigationBarView (`https://developer.android.com/reference/com/google/android/material/bottomnavigation/BottomNavigationView.html` or `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView.html`) that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController that supplies the primary menu. Navigation actions on this NavController will be reflected in the selected item in the NavigationBarView. |

### setupWithNavController

Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.0.0)

```
public static final void setupWithNavController(
    @NonNull NavigationView navigationView,
    @NonNull NavController navController
)
```

Sets up a `https://developer.android.com/reference/com/google/android/material/navigation/NavigationView.html` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. This will call `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#onNavDestinationSelected(android.view.MenuItem,androidx.navigation.NavController)` when a menu item is selected. The selected item in the NavigationView will automatically be updated when the destination changes.

If the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationView.html` is directly contained with an `https://developer.android.com/reference/androidx/customview/widget/Openable` layout, it will be closed when a menu item is selected.

Similarly, if the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationView.html` has a `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior.html` associated with it (as is the case when using a `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog.html`), the bottom sheet will be hidden when a menu item is selected.

Destinations that implement `https://developer.android.com/reference/androidx/navigation/FloatingWindow` will be ignored.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/navigation/NavigationView.html navigationView` | The NavigationView that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController that supplies the primary and secondary menu. Navigation actions on this NavController will be reflected in the selected item in the NavigationView. |

### setupWithNavController

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
@NavigationUiSaveStateControl
public static final void setupWithNavController(
    @NonNull NavigationBarView navigationBarView,
    @NonNull NavController navController,
    boolean saveState
)
```

Sets up a `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.html` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. This will call `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#onNavDestinationSelected(android.view.MenuItem,androidx.navigation.NavController)` when a menu item is selected. The selected item in the NavigationBarView will automatically be updated when the destination changes.

Destinations that implement `https://developer.android.com/reference/androidx/navigation/FloatingWindow` will be ignored.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.html navigationBarView` | The NavigationBarView (`https://developer.android.com/reference/com/google/android/material/bottomnavigation/BottomNavigationView.html` or `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView.html`) that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController that supplies the primary menu. |
| `boolean saveState` | Whether the NavController should save the back stack state. This must always be `false`: leave this parameter off entirely to use the non-experimental version of this API, which saves the state by default. Navigation actions on this NavController will be reflected in the selected item in the NavigationBarView. |

### setupWithNavController

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
@NavigationUiSaveStateControl
public static final void setupWithNavController(
    @NonNull NavigationView navigationView,
    @NonNull NavController navController,
    boolean saveState
)
```

Sets up a `https://developer.android.com/reference/com/google/android/material/navigation/NavigationView.html` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. This will call `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#onNavDestinationSelected(android.view.MenuItem,androidx.navigation.NavController)` when a menu item is selected. The selected item in the NavigationView will automatically be updated when the destination changes.

If the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationView.html` is directly contained with an `https://developer.android.com/reference/androidx/customview/widget/Openable` layout, it will be closed when a menu item is selected.

Similarly, if the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationView.html` has a `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior.html` associated with it (as is the case when using a `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog.html`), the bottom sheet will be hidden when a menu item is selected.

Destinations that implement `https://developer.android.com/reference/androidx/navigation/FloatingWindow` will be ignored.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/navigation/NavigationView.html navigationView` | The NavigationView that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController that supplies the primary and secondary menu. |
| `boolean saveState` | Whether the NavController should save the back stack state. This must always be `false`: leave this parameter off entirely to use the non-experimental version of this API, which saves the state by default. Navigation actions on this NavController will be reflected in the selected item in the NavigationView. |

### setupWithNavController

Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.0.0)

```
public static final void setupWithNavController(
    @NonNull Toolbar toolbar,
    @NonNull NavController navController,
    @NonNull AppBarConfiguration configuration
)
```

Sets up a `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`.

By calling this method, the title in the Toolbar will automatically be updated when the destination changes (assuming there is a valid `https://developer.android.com/reference/androidx/navigation/NavDestination#label()`).

The `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration` you provide controls how the Navigation button is displayed and what action is triggered when the Navigation button is tapped. This method will call `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#navigateUp(androidx.navigation.NavController,androidx.customview.widget.Openable)` when the Navigation button is clicked.

Destinations that implement `https://developer.android.com/reference/androidx/navigation/FloatingWindow` will be ignored.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar` | The Toolbar that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController whose navigation actions will be reflected in the title of the Toolbar. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration configuration` | Additional configuration options for customizing the behavior of the Toolbar |

### setupWithNavController

Added in [2.3.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.3.0)

```
public static final void setupWithNavController(
    @NonNull Toolbar toolbar,
    @NonNull NavController navController,
    Openable openableLayout
)
```

Sets up a `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`.

By calling this method, the title in the Toolbar will automatically be updated when the destination changes (assuming there is a valid `https://developer.android.com/reference/androidx/navigation/NavDestination#label()`).

The start destination of your navigation graph is considered the only top level destination. On the start destination of your navigation graph, the Toolbar will show the drawer icon if the given Openable layout is non null. On all other destinations, the Toolbar will show the Up button. This method will call `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#navigateUp(androidx.navigation.NavController,androidx.customview.widget.Openable)` when the Navigation button is clicked.

Destinations that implement `https://developer.android.com/reference/androidx/navigation/FloatingWindow` will be ignored.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar` | The Toolbar that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController whose navigation actions will be reflected in the title of the Toolbar. |
| `https://developer.android.com/reference/androidx/customview/widget/Openable openableLayout` | The Openable layout that should be toggled from the Navigation button |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#setupWithNavController(androidx.appcompat.widget.Toolbar,androidx.navigation.NavController,androidx.customview.widget.Openable)` |   |

### setupWithNavController

Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.0.0)

```
public static final void setupWithNavController(
    @NonNull CollapsingToolbarLayout collapsingToolbarLayout,
    @NonNull Toolbar toolbar,
    @NonNull NavController navController,
    @NonNull AppBarConfiguration configuration
)
```

Sets up a `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html` and `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`.

By calling this method, the title in the CollapsingToolbarLayout will automatically be updated when the destination changes (assuming there is a valid `https://developer.android.com/reference/androidx/navigation/NavDestination#label()`).

The `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration` you provide controls how the Navigation button is displayed and what action is triggered when the Navigation button is tapped. This method will call `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#navigateUp(androidx.navigation.NavController,androidx.customview.widget.Openable)` when the Navigation button is clicked.

Destinations that implement `https://developer.android.com/reference/androidx/navigation/FloatingWindow` will be ignored.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html collapsingToolbarLayout` | The CollapsingToolbarLayout that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar` | The Toolbar that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController whose navigation actions will be reflected in the title of the Toolbar. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration configuration` | Additional configuration options for customizing the behavior of the Toolbar |

### setupWithNavController

Added in [2.3.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.3.0)

```
public static final void setupWithNavController(
    @NonNull CollapsingToolbarLayout collapsingToolbarLayout,
    @NonNull Toolbar toolbar,
    @NonNull NavController navController,
    Openable openableLayout
)
```

Sets up a `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html` and `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`.

By calling this method, the title in the CollapsingToolbarLayout will automatically be updated when the destination changes (assuming there is a valid `https://developer.android.com/reference/androidx/navigation/NavDestination#label()`).

The start destination of your navigation graph is considered the only top level destination. On the start destination of your navigation graph, the Toolbar will show the drawer icon if the given Openable layout is non null. On all other destinations, the Toolbar will show the Up button. This method will call `https://developer.android.com/reference/androidx/navigation/ui/NavigationUI#navigateUp(androidx.navigation.NavController,androidx.customview.widget.Openable)` when the Navigation button is clicked.

Destinations that implement `https://developer.android.com/reference/androidx/navigation/FloatingWindow` will be ignored.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html collapsingToolbarLayout` | The CollapsingToolbarLayout that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar` | The Toolbar that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController whose navigation actions will be reflected in the title of the Toolbar. |
| `https://developer.android.com/reference/androidx/customview/widget/Openable openableLayout` | The Openable layout that should be toggled from the Navigation button |