# AppBarConfiguration.Builder

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/AppBarConfiguration.kt+class:androidx.navigation.ui.AppBarConfiguration.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

*** ** * ** ***

<br />

```
public final class AppBarConfiguration.Builder
```

<br />

*** ** * ** ***

The Builder class for constructing new `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder#Builder(androidx.navigation.NavGraph)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph navGraph)` Create a new Builder whose only top level destination is the start destination of the given `https://developer.android.com/reference/androidx/navigation/NavGraph`. |
| `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder#Builder(kotlin.IntArray)(int... topLevelDestinationIds)` Create a new Builder with a specific set of top level destinations. |
| `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder#Builder(kotlin.collections.Set)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html> topLevelDestinationIds)` Create a new Builder with a specific set of top level destinations. |
| `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder#Builder(android.view.Menu)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/Menu.html topLevelMenu)` Create a new Builder using a `https://developer.android.com/reference/android/view/Menu.html` containing all top level destinations. |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration` | `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder#build()()` Construct the `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration` instance. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder` | `[setDrawerLayout](https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder#setDrawerLayout(androidx.drawerlayout.widget.DrawerLayout))(https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout drawerLayout)` **This method is deprecated.** Use {@link #setOpenableLayout(Openable)}. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder` | `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder#setFallbackOnNavigateUpListener(androidx.navigation.ui.AppBarConfiguration.OnNavigateUpListener)( https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.OnNavigateUpListener fallbackOnNavigateUpListener )` Adds a `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.OnNavigateUpListener` that will be called as a fallback if the default behavior of `https://developer.android.com/reference/androidx/navigation/NavController#navigateUp()` returns `false`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder` | `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder#setOpenableLayout(androidx.customview.widget.Openable)(https://developer.android.com/reference/androidx/customview/widget/Openable openableLayout)` Display the Navigation button as a drawer symbol when it is not being shown as an Up button. |

## Public constructors

### Builder

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

```
public Builder(@NonNull NavGraph navGraph)
```

Create a new Builder whose only top level destination is the start destination of the given `https://developer.android.com/reference/androidx/navigation/NavGraph`. The Up button will not be displayed when on the start destination of the graph.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph navGraph` | The NavGraph whose start destination should be considered the only top level destination. The Up button will not be displayed when on the start destination of the graph. |

### Builder

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

```
public Builder(int... topLevelDestinationIds)
```

Create a new Builder with a specific set of top level destinations. The Up button will not be displayed when on these destinations.

| Parameters |
|---|---|
| `int... topLevelDestinationIds` | The set of destinations by id considered at the top level of your information hierarchy. The Up button will not be displayed when on these destinations. |

### Builder

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

```
public Builder(@NonNull Set<@NonNull Integer> topLevelDestinationIds)
```

Create a new Builder with a specific set of top level destinations. The Up button will not be displayed when on these destinations.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html> topLevelDestinationIds` | The set of destinations by id considered at the top level of your information hierarchy. The Up button will not be displayed when on these destinations. |

### Builder

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

```
public Builder(@NonNull Menu topLevelMenu)
```

Create a new Builder using a `https://developer.android.com/reference/android/view/Menu.html` containing all top level destinations. It is expected that the `https://developer.android.com/reference/android/view/MenuItem.html#getItemId()` of each item corresponds with a destination in your navigation graph. The Up button will not be displayed when on these destinations.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/Menu.html topLevelMenu` | A Menu containing MenuItems corresponding with the destinations considered at the top level of your information hierarchy. The Up button will not be displayed when on these destinations. |

## Public methods

### build

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

```
public final @NonNull AppBarConfiguration build()
```

Construct the `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration` instance.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration` | a valid `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration` |

### setDrawerLayout

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

```
public final @NonNull AppBarConfiguration.Builder [setDrawerLayout](https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder#setDrawerLayout(androidx.drawerlayout.widget.DrawerLayout))(DrawerLayout drawerLayout)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use {@link #setOpenableLayout(Openable)}.

Display the Navigation button as a drawer symbol when it is not being shown as an Up button.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout drawerLayout` | The DrawerLayout that should be toggled from the Navigation button |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder` | this `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder` |

### setFallbackOnNavigateUpListener

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

```
public final @NonNull AppBarConfiguration.Builder setFallbackOnNavigateUpListener(
    AppBarConfiguration.OnNavigateUpListener fallbackOnNavigateUpListener
)
```

Adds a `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.OnNavigateUpListener` that will be called as a fallback if the default behavior of `https://developer.android.com/reference/androidx/navigation/NavController#navigateUp()` returns `false`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.OnNavigateUpListener fallbackOnNavigateUpListener` | Listener that will be invoked if `https://developer.android.com/reference/androidx/navigation/NavController#navigateUp()` returns `false`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder` | this `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder` |

### setOpenableLayout

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

```
public final @NonNull AppBarConfiguration.Builder setOpenableLayout(Openable openableLayout)
```

Display the Navigation button as a drawer symbol when it is not being shown as an Up button.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/customview/widget/Openable openableLayout` | The Openable layout that should be toggled from the Navigation button |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder` | this `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration.Builder` |