# MenuItemKt

Added in 2.4.0

*** ** * ** ***


```
public final class MenuItemKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final boolean` | `https://developer.android.com/reference/androidx/navigation/ui/MenuItemKt#(android.view.MenuItem).onNavDestinationSelected(androidx.navigation.NavController)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/MenuItem.html receiver, @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 this `https://developer.android.com/reference/android/view/MenuItem.html`. |

## Public methods

### onNavDestinationSelected

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/MenuItem.kt+function:onNavDestinationSelected) Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

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

Attempt to navigate to the `https://developer.android.com/reference/androidx/navigation/NavDestination` associated with this `https://developer.android.com/reference/android/view/MenuItem.html`.

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.

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