# MenuItemCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/MenuItemCompat.java+class:androidx.core.view.MenuItemCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
public final class MenuItemCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/view/MenuItem.html`.

**Note:** You cannot get an instance of this class. Instead, it provides *static* methods that correspond to the methods in `https://developer.android.com/reference/android/view/MenuItem.html`, but take a `https://developer.android.com/reference/android/view/MenuItem.html` object as an additional argument.

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/core/view/MenuItemCompat.OnActionExpandListener` **This interface is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.OnActionExpandListener.html` directly. <br /> |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#SHOW_AS_ACTION_ALWAYS() = 2` **This field is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.html#SHOW_AS_ACTION_ALWAYS` directly. <br /> |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW() = 8` **This field is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.html#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW` directly. <br /> |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#SHOW_AS_ACTION_IF_ROOM() = 1` **This field is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.html#SHOW_AS_ACTION_IF_ROOM` directly. <br /> |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#SHOW_AS_ACTION_NEVER() = 0` **This field is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.html#SHOW_AS_ACTION_NEVER` directly. <br /> |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#SHOW_AS_ACTION_WITH_TEXT() = 4` **This field is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.html#SHOW_AS_ACTION_WITH_TEXT` directly. <br /> |

| ### Public methods |
|---|---|
| `static boolean` | `@https://developer.android.com/reference/androidx/annotation/ReplaceWith(expression = "item.collapseActionView()") [collapseActionView](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#collapseActionView(android.view.MenuItem))(https://developer.android.com/reference/android/view/MenuItem.html item)` **This method is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.html#collapseActionView()` directly. <br /> |
| `static boolean` | `@https://developer.android.com/reference/androidx/annotation/ReplaceWith(expression = "item.expandActionView()") [expandActionView](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#expandActionView(android.view.MenuItem))(https://developer.android.com/reference/android/view/MenuItem.html item)` **This method is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.html#expandActionView()` directly. <br /> |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/view/ActionProvider` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#getActionProvider(android.view.MenuItem)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item)` Gets the `https://developer.android.com/reference/androidx/core/view/ActionProvider`. |
| `static https://developer.android.com/reference/android/view/View.html` | `@https://developer.android.com/reference/androidx/annotation/ReplaceWith(expression = "item.getActionView()") [getActionView](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#getActionView(android.view.MenuItem))(https://developer.android.com/reference/android/view/MenuItem.html item)` **This method is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.html#getActionView()` directly. <br /> |
| `static int` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#getAlphabeticModifiers(android.view.MenuItem)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item)` Return the modifier for this menu item's alphabetic shortcut. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#getContentDescription(android.view.MenuItem)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item)` Retrieve the content description associated with this menu item. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/res/ColorStateList.html` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#getIconTintList(android.view.MenuItem)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item)` |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#getIconTintMode(android.view.MenuItem)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item)` Returns the blending mode used to apply the tint to the item's icon, if specified. |
| `static int` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#getNumericModifiers(android.view.MenuItem)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item)` Return the modifiers for this menu item's numeric (12-key) shortcut. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#getTooltipText(android.view.MenuItem)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item)` Retrieve the tooltip text associated with this menu item. |
| `static boolean` | `@https://developer.android.com/reference/androidx/annotation/ReplaceWith(expression = "item.isActionViewExpanded()") [isActionViewExpanded](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#isActionViewExpanded(android.view.MenuItem))(https://developer.android.com/reference/android/view/MenuItem.html item)` **This method is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.html#isActionViewExpanded()` directly. <br /> |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/MenuItem.html` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setActionProvider(android.view.MenuItem,androidx.core.view.ActionProvider)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/view/ActionProvider provider )` Sets the `https://developer.android.com/reference/androidx/core/view/ActionProvider` responsible for creating an action view if the item is placed on the action bar. |
| `static https://developer.android.com/reference/android/view/MenuItem.html` | `@https://developer.android.com/reference/androidx/annotation/ReplaceWith(expression = "item.setActionView(resId)") [setActionView](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setActionView(android.view.MenuItem,int))(https://developer.android.com/reference/android/view/MenuItem.html item, int resId)` **This method is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.html#setActionView(int)` directly. <br /> |
| `static https://developer.android.com/reference/android/view/MenuItem.html` | `@https://developer.android.com/reference/androidx/annotation/ReplaceWith(expression = "item.setActionView(view)") [setActionView](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setActionView(android.view.MenuItem,android.view.View))(https://developer.android.com/reference/android/view/MenuItem.html item, https://developer.android.com/reference/android/view/View.html view)` **This method is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.html#setActionView(android.view.View)` directly. <br /> |
| `static void` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setAlphabeticShortcut(android.view.MenuItem,char,int)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item, char alphaChar, int alphaModifiers )` Change the alphabetic shortcut associated with this item. |
| `static void` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setContentDescription(android.view.MenuItem,java.lang.CharSequence)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html contentDescription )` Change the content description associated with this menu item. |
| `static void` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setIconTintList(android.view.MenuItem,android.content.res.ColorStateList)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/res/ColorStateList.html tint)` Applies a tint to the item's icon. |
| `static void` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setIconTintMode(android.view.MenuItem,android.graphics.PorterDuff.Mode)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html tintMode)` Specifies the blending mode used to apply the tint specified by `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setIconTintList(android.view.MenuItem,android.content.res.ColorStateList)` to the item's icon. |
| `static void` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setNumericShortcut(android.view.MenuItem,char,int)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item, char numericChar, int numericModifiers )` Change the numeric shortcut and modifiers associated with this item. |
| `static https://developer.android.com/reference/android/view/MenuItem.html` | `[setOnActionExpandListener](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setOnActionExpandListener(android.view.MenuItem,androidx.core.view.MenuItemCompat.OnActionExpandListener))( https://developer.android.com/reference/android/view/MenuItem.html item, https://developer.android.com/reference/androidx/core/view/MenuItemCompat.OnActionExpandListener listener )` **This method is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.html#setOnActionExpandListener(android.view.MenuItem.OnActionExpandListener)` directly. <br /> |
| `static void` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setShortcut(android.view.MenuItem,char,char,int,int)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item, char numericChar, char alphaChar, int numericModifiers, int alphaModifiers )` Change both the numeric and alphabetic shortcut associated with this item. |
| `static void` | `@https://developer.android.com/reference/androidx/annotation/ReplaceWith(expression = "item.setShowAsAction(actionEnum)") [setShowAsAction](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setShowAsAction(android.view.MenuItem,int))(https://developer.android.com/reference/android/view/MenuItem.html item, int actionEnum)` **This method is deprecated.** Use `https://developer.android.com/reference/android/view/MenuItem.html#setShowAsAction(int)` directly. <br /> |
| `static void` | `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setTooltipText(android.view.MenuItem,java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html tooltipText)` Change the tooltip text associated with this menu item. |

## Constants

### SHOW_AS_ACTION_ALWAYS

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SHOW_AS_ACTION_ALWAYS = 2
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/android/view/MenuItem.html#SHOW_AS_ACTION_ALWAYS` directly.

Always show this item as a button in an Action Bar. Use sparingly! If too many items are set to always show in the Action Bar it can crowd the Action Bar and degrade the user experience on devices with smaller screens. A good rule of thumb is to have no more than 2 items set to always show at a time.

### SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW = 8
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/android/view/MenuItem.html#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW` directly.

This item's action view collapses to a normal menu item. When expanded, the action view temporarily takes over a larger segment of its container.

### SHOW_AS_ACTION_IF_ROOM

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SHOW_AS_ACTION_IF_ROOM = 1
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/android/view/MenuItem.html#SHOW_AS_ACTION_IF_ROOM` directly.

Show this item as a button in an Action Bar if the system decides there is room for it.

### SHOW_AS_ACTION_NEVER

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SHOW_AS_ACTION_NEVER = 0
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/android/view/MenuItem.html#SHOW_AS_ACTION_NEVER` directly.

Never show this item as a button in an Action Bar.

### SHOW_AS_ACTION_WITH_TEXT

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SHOW_AS_ACTION_WITH_TEXT = 4
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/android/view/MenuItem.html#SHOW_AS_ACTION_WITH_TEXT` directly.

When this item is in the action bar, always show it with a text label even if it also has an icon specified.

## Public methods

### collapseActionView

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
@ReplaceWith(expression = "item.collapseActionView()")
public static boolean [collapseActionView](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#collapseActionView(android.view.MenuItem))(MenuItem item)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/view/MenuItem.html#collapseActionView()` directly.

Collapse the action view associated with this menu item. The menu item must have an action view set, as well as the showAsAction flag `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW()`. If a listener has been set using `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setOnActionExpandListener(android.view.MenuItem,androidx.core.view.MenuItemCompat.OnActionExpandListener)` it will have its `https://developer.android.com/reference/androidx/core/view/MenuItemCompat.OnActionExpandListener#onMenuItemActionCollapse(android.view.MenuItem)` method invoked. The listener may return false from this method to prevent collapsing the action view.

| Returns |
|---|---|
| `boolean` | true if the action view was collapsed, false otherwise. |

### expandActionView

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
@ReplaceWith(expression = "item.expandActionView()")
public static boolean [expandActionView](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#expandActionView(android.view.MenuItem))(MenuItem item)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/view/MenuItem.html#expandActionView()` directly.

Expand the action view associated with this menu item. The menu item must have an action view set, as well as the showAsAction flag `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW()`. If a listener has been set using `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setOnActionExpandListener(android.view.MenuItem,androidx.core.view.MenuItemCompat.OnActionExpandListener)` it will have its `https://developer.android.com/reference/androidx/core/view/MenuItemCompat.OnActionExpandListener#onMenuItemActionExpand(android.view.MenuItem)` method invoked. The listener may return false from this method to prevent expanding the action view.

| Returns |
|---|---|
| `boolean` | true if the action view was expanded, false otherwise. |

### getActionProvider

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

```
public static @Nullable ActionProvider getActionProvider(@NonNull MenuItem item)
```

Gets the `https://developer.android.com/reference/androidx/core/view/ActionProvider`.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/view/ActionProvider` | The action provider. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/ActionProvider` |   |
| `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setActionProvider(android.view.MenuItem,androidx.core.view.ActionProvider)` |   |

### getActionView

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
@ReplaceWith(expression = "item.getActionView()")
public static View [getActionView](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#getActionView(android.view.MenuItem))(MenuItem item)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/view/MenuItem.html#getActionView()` directly.

Returns the currently set action view for this menu item.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem.html item` | the item to query |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/view/View.html` | This item's action view |

### getAlphabeticModifiers

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

```
public static int getAlphabeticModifiers(@NonNull MenuItem item)
```

Return the modifier for this menu item's alphabetic shortcut. The modifier is a combination of `https://developer.android.com/reference/android/view/KeyEvent.html#META_META_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_CTRL_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_ALT_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_SHIFT_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_SYM_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_FUNCTION_ON`. For example, `https://developer.android.com/reference/android/view/KeyEvent.html#META_FUNCTION_ON`\|`https://developer.android.com/reference/android/view/KeyEvent.html#META_CTRL_ON`

| Returns |
|---|---|
| `int` | Modifier associated with the keyboard shortcut. |

### getContentDescription

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

```
public static @Nullable CharSequence getContentDescription(@NonNull MenuItem item)
```

Retrieve the content description associated with this menu item.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html` | The content description. |

### getIconTintList

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

```
public static @Nullable ColorStateList getIconTintList(@NonNull MenuItem item)
```

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/res/ColorStateList.html` | the tint applied to the item's icon |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setIconTintList(android.view.MenuItem,android.content.res.ColorStateList)` |   |

### getIconTintMode

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

```
public static @Nullable PorterDuff.Mode getIconTintMode(@NonNull MenuItem item)
```

Returns the blending mode used to apply the tint to the item's icon, if specified.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html` | the blending mode used to apply the tint to the item's icon |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setIconTintMode(android.view.MenuItem,android.graphics.PorterDuff.Mode)` |   |

### getNumericModifiers

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

```
public static int getNumericModifiers(@NonNull MenuItem item)
```

Return the modifiers for this menu item's numeric (12-key) shortcut. The modifier is a combination of `https://developer.android.com/reference/android/view/KeyEvent.html#META_META_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_CTRL_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_ALT_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_SHIFT_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_SYM_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_FUNCTION_ON`. For example, `https://developer.android.com/reference/android/view/KeyEvent.html#META_FUNCTION_ON`\|`https://developer.android.com/reference/android/view/KeyEvent.html#META_CTRL_ON`

| Returns |
|---|---|
| `int` | Modifier associated with the numeric shortcut. |

### getTooltipText

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

```
public static @Nullable CharSequence getTooltipText(@NonNull MenuItem item)
```

Retrieve the tooltip text associated with this menu item.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html` | The tooltip text. |

### isActionViewExpanded

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
@ReplaceWith(expression = "item.isActionViewExpanded()")
public static boolean [isActionViewExpanded](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#isActionViewExpanded(android.view.MenuItem))(MenuItem item)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/view/MenuItem.html#isActionViewExpanded()` directly.

Returns true if this menu item's action view has been expanded.

| Returns |
|---|---|
| `boolean` | true if the item's action view is expanded, false otherwise. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#expandActionView(android.view.MenuItem)` |   |
| `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#collapseActionView(android.view.MenuItem)` |   |
| `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW()` |   |
| `https://developer.android.com/reference/androidx/core/view/MenuItemCompat.OnActionExpandListener` |   |

### setActionProvider

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

```
public static @Nullable MenuItem setActionProvider(
    @NonNull MenuItem item,
    @Nullable ActionProvider provider
)
```

Sets the `https://developer.android.com/reference/androidx/core/view/ActionProvider` responsible for creating an action view if the item is placed on the action bar. The provider also provides a default action invoked if the item is placed in the overflow menu.

**Note:** Setting an action provider overrides the action view set via `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setActionView(android.view.MenuItem,android.view.View)`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item` | item to change |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/view/ActionProvider provider` | The action provider. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/MenuItem.html` | This Item so additional setters can be called. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/ActionProvider` |   |

### setActionView

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
@ReplaceWith(expression = "item.setActionView(resId)")
public static MenuItem [setActionView](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setActionView(android.view.MenuItem,int))(MenuItem item, int resId)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/view/MenuItem.html#setActionView(int)` directly.

Set an action view for this menu item. An action view will be displayed in place of an automatically generated menu item element in the UI when this item is shown as an action within a parent.

**Note:** Setting an action view overrides the action provider set via `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setActionProvider(android.view.MenuItem,androidx.core.view.ActionProvider)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem.html item` | the item to change |
| `int resId` | Layout resource to use for presenting this item to the user. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem.html` | This Item so additional setters can be called. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setShowAsAction(android.view.MenuItem,int)` |   |

### setActionView

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
@ReplaceWith(expression = "item.setActionView(view)")
public static MenuItem [setActionView](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setActionView(android.view.MenuItem,android.view.View))(MenuItem item, View view)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/view/MenuItem.html#setActionView(android.view.View)` directly.

Set an action view for this menu item. An action view will be displayed in place of an automatically generated menu item element in the UI when this item is shown as an action within a parent.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem.html item` | the item to change |
| `https://developer.android.com/reference/android/view/View.html view` | View to use for presenting this item to the user. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem.html` | This Item so additional setters can be called. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setShowAsAction(android.view.MenuItem,int)` |   |

### setAlphabeticShortcut

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

```
public static void setAlphabeticShortcut(
    @NonNull MenuItem item,
    char alphaChar,
    int alphaModifiers
)
```

Change the alphabetic shortcut associated with this item. The shortcut will be triggered when the key that generates the given character is pressed along with the modifier keys. Case is not significant and shortcut characters will be displayed in lower case. Note that menu items with the characters '\\b' or '\\n' as shortcuts will get triggered by the Delete key or Carriage Return key, respectively.

See `https://developer.android.com/reference/android/view/Menu.html` for the menu types that support shortcuts.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item` | item for which to set the shortcut. |
| `char alphaChar` | The alphabetic shortcut key. This is the shortcut when using a keyboard with alphabetic keys. |
| `int alphaModifiers` | The modifier associated with the shortcut. It should be a combination of `https://developer.android.com/reference/android/view/KeyEvent.html#META_META_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_CTRL_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_ALT_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_SHIFT_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_SYM_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_FUNCTION_ON`. |

### setContentDescription

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

```
public static void setContentDescription(
    @NonNull MenuItem item,
    @Nullable CharSequence contentDescription
)
```

Change the content description associated with this menu item.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item` | item to change. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html contentDescription` | The new content description. |

### setIconTintList

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

```
public static void setIconTintList(@NonNull MenuItem item, @Nullable ColorStateList tint)
```

Applies a tint to the item's icon. Does not modify the current tint mode of that item, which is `https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html#SRC_IN` by default.

Subsequent calls to `https://developer.android.com/reference/android/view/MenuItem.html#setIcon(android.graphics.drawable.Drawable)` or `https://developer.android.com/reference/android/view/MenuItem.html#setIcon(int)` will automatically mutate the icon and apply the specified tint and tint mode.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item` | item for which to set the tint. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/res/ColorStateList.html tint` | the tint to apply, may be `null` to clear tint |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#getIconTintList(android.view.MenuItem)` |   |

### setIconTintMode

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

```
public static void setIconTintMode(@NonNull MenuItem item, @Nullable PorterDuff.Mode tintMode)
```

Specifies the blending mode used to apply the tint specified by `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setIconTintList(android.view.MenuItem,android.content.res.ColorStateList)` to the item's icon. The default mode is `https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html#SRC_IN`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item` | item for which to set the tint mode. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html tintMode` | the blending mode used to apply the tint, may be `null` to clear tint |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setIconTintList(android.view.MenuItem,android.content.res.ColorStateList)` |   |

### setNumericShortcut

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

```
public static void setNumericShortcut(
    @NonNull MenuItem item,
    char numericChar,
    int numericModifiers
)
```

Change the numeric shortcut and modifiers associated with this item.

See `https://developer.android.com/reference/android/view/Menu.html` for the menu types that support shortcuts.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item` | item for which to set the shortcut. |
| `char numericChar` | The numeric shortcut key. This is the shortcut when using a 12-key (numeric) keyboard. |
| `int numericModifiers` | The modifier associated with the shortcut. It should be a combination of `https://developer.android.com/reference/android/view/KeyEvent.html#META_META_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_CTRL_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_ALT_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_SHIFT_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_SYM_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_FUNCTION_ON`. |

### setOnActionExpandListener

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static MenuItem [setOnActionExpandListener](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setOnActionExpandListener(android.view.MenuItem,androidx.core.view.MenuItemCompat.OnActionExpandListener))(
    MenuItem item,
    MenuItemCompat.OnActionExpandListener listener
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/view/MenuItem.html#setOnActionExpandListener(android.view.MenuItem.OnActionExpandListener)` directly.

Set an `https://developer.android.com/reference/androidx/core/view/MenuItemCompat.OnActionExpandListener` on this menu item to be notified when the associated action view is expanded or collapsed. The menu item must be configured to expand or collapse its action view using the flag `https://developer.android.com/reference/androidx/core/view/MenuItemCompat#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem.html item` | item on which to set the listener. |
| `https://developer.android.com/reference/androidx/core/view/MenuItemCompat.OnActionExpandListener listener` | Listener that will respond to expand/collapse events |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem.html` | This menu item instance for call chaining |

### setShortcut

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

```
public static void setShortcut(
    @NonNull MenuItem item,
    char numericChar,
    char alphaChar,
    int numericModifiers,
    int alphaModifiers
)
```

Change both the numeric and alphabetic shortcut associated with this item. Note that the shortcut will be triggered when the key that generates the given character is pressed along with the corresponding modifier key. Also note that case is not significant and that alphabetic shortcut characters will be handled in lower case.

See `https://developer.android.com/reference/android/view/Menu.html` for the menu types that support shortcuts.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item` | item for which to set the shortcut. |
| `char numericChar` | The numeric shortcut key. This is the shortcut when using a numeric (e.g., 12-key) keyboard. |
| `char alphaChar` | The alphabetic shortcut key. This is the shortcut when using a keyboard with alphabetic keys. |
| `int numericModifiers` | The numeric modifier associated with the shortcut. It should be a combination of `https://developer.android.com/reference/android/view/KeyEvent.html#META_META_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_CTRL_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_ALT_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_SHIFT_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_SYM_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_FUNCTION_ON`. |
| `int alphaModifiers` | The alphabetic modifier associated with the shortcut. It should be a combination of `https://developer.android.com/reference/android/view/KeyEvent.html#META_META_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_CTRL_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_ALT_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_SHIFT_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_SYM_ON`, `https://developer.android.com/reference/android/view/KeyEvent.html#META_FUNCTION_ON`. |

### setShowAsAction

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
@ReplaceWith(expression = "item.setShowAsAction(actionEnum)")
public static void [setShowAsAction](https://developer.android.com/reference/androidx/core/view/MenuItemCompat#setShowAsAction(android.view.MenuItem,int))(MenuItem item, int actionEnum)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/view/MenuItem.html#setShowAsAction(int)` directly.

Sets how this item should display in the presence of a compatible Action Bar. If the given item is compatible, this will call the item's supported implementation of `https://developer.android.com/reference/android/view/MenuItem.html#setShowAsAction(int)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem.html item` | - the item to change |
| `int actionEnum` | - How the item should display. |

### setTooltipText

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

```
public static void setTooltipText(@NonNull MenuItem item, @Nullable CharSequence tooltipText)
```

Change the tooltip text associated with this menu item.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item` | item to change. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html tooltipText` | The new tooltip text |