Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/view/Menu#constants) \| [Methods](https://developer.android.com/reference/android/view/Menu#pubmethods)

# Menu

*** ** * ** ***

` public interface Menu `   
` `

|---|
| android.view.Menu |

Known indirect subclasses [ContextMenu](https://developer.android.com/reference/android/view/ContextMenu), [SubMenu](https://developer.android.com/reference/android/view/SubMenu) [ContextMenu](https://developer.android.com/reference/android/view/ContextMenu) Extension of `https://developer.android.com/reference/android/view/Menu` for context menus providing functionality to modify the header of the context menu. [SubMenu](https://developer.android.com/reference/android/view/SubMenu) Subclass of `https://developer.android.com/reference/android/view/Menu` for sub menus.   

*** ** * ** ***

Interface for managing the items in a menu.

By default, every Activity supports an options menu of actions or options. You can add items to this menu and handle clicks on your additions. The easiest way of adding menu items is inflating an XML file into the `https://developer.android.com/reference/android/view/Menu` via `https://developer.android.com/reference/android/view/MenuInflater`. The easiest way of attaching code to clicks is via `https://developer.android.com/reference/android/app/Activity#onOptionsItemSelected(android.view.MenuItem)` and `https://developer.android.com/reference/android/app/Activity#onContextItemSelected(android.view.MenuItem)`.

Different menu types support different features:

1. **Context menus**: Do not support item shortcuts and item icons.
2. **Options menus** : The **icon menus** do not support item check marks and only show the item's `https://developer.android.com/reference/android/view/MenuItem#setTitleCondensed(java.lang.CharSequence)`. The **expanded menus** (only available if six or more menu items are visible, reached via the 'More' item in the icon menu) do not show item icons, and item check marks are discouraged.
3. **Sub menus**: Do not support item icons, or nested sub menus.

### Developer Guides

For more information about creating menus, read the [Menus](https://developer.android.com/guide/topics/ui/menus) developer guide.

<br />

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/view/Menu#CATEGORY_ALTERNATIVE` Category code for the order integer for items/groups that are alternative actions on the data that is currently displayed -- or/add this with your base value. |
| `int` | `https://developer.android.com/reference/android/view/Menu#CATEGORY_CONTAINER` Category code for the order integer for items/groups that are part of a container -- or/add this with your base value. |
| `int` | `https://developer.android.com/reference/android/view/Menu#CATEGORY_SECONDARY` Category code for the order integer for items/groups that are user-supplied secondary (infrequently used) options -- or/add this with your base value. |
| `int` | `https://developer.android.com/reference/android/view/Menu#CATEGORY_SYSTEM` Category code for the order integer for items/groups that are provided by the system -- or/add this with your base value. |
| `int` | `https://developer.android.com/reference/android/view/Menu#FIRST` First value for group and item identifier integers. |
| `int` | `https://developer.android.com/reference/android/view/Menu#FLAG_ALWAYS_PERFORM_CLOSE` Flag for `https://developer.android.com/reference/android/view/Menu#performShortcut(int,%20android.view.KeyEvent,%20int)`: if set, always close the menu after executing the shortcut. |
| `int` | `https://developer.android.com/reference/android/view/Menu#FLAG_APPEND_TO_GROUP` Flag for `https://developer.android.com/reference/android/view/Menu#addIntentOptions(int,%20int,%20int,%20android.content.ComponentName,%20android.content.Intent[],%20android.content.Intent,%20int,%20android.view.MenuItem[])`: if set, do not automatically remove any existing menu items in the same group. |
| `int` | `https://developer.android.com/reference/android/view/Menu#FLAG_PERFORM_NO_CLOSE` Flag for `https://developer.android.com/reference/android/view/Menu#performShortcut(int,%20android.view.KeyEvent,%20int)`: if set, do not close the menu after executing the shortcut. |
| `int` | `https://developer.android.com/reference/android/view/Menu#NONE` Value to use for group and item identifier integers when you don't care about them. |
| `int` | `https://developer.android.com/reference/android/view/Menu#SUPPORTED_MODIFIERS_MASK` A mask of all supported modifiers for MenuItem's keyboard shortcuts |

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/android/view/MenuItem` | ` https://developer.android.com/reference/android/view/Menu#add(int,%20int,%20int,%20java.lang.CharSequence)(int groupId, int itemId, int order, https://developer.android.com/reference/java/lang/CharSequence title) ` Add a new item to the menu. |
| ` abstract https://developer.android.com/reference/android/view/MenuItem` | ` https://developer.android.com/reference/android/view/Menu#add(int)(int titleRes) ` Add a new item to the menu. |
| ` abstract https://developer.android.com/reference/android/view/MenuItem` | ` https://developer.android.com/reference/android/view/Menu#add(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence title) ` Add a new item to the menu. |
| ` abstract https://developer.android.com/reference/android/view/MenuItem` | ` https://developer.android.com/reference/android/view/Menu#add(int,%20int,%20int,%20int)(int groupId, int itemId, int order, int titleRes) ` Variation on `https://developer.android.com/reference/android/view/Menu#add(int,%20int,%20int,%20java.lang.CharSequence)` that takes a string resource identifier instead of the string itself. |
| ` abstract int` | ` https://developer.android.com/reference/android/view/Menu#addIntentOptions(int,%20int,%20int,%20android.content.ComponentName,%20android.content.Intent[],%20android.content.Intent,%20int,%20android.view.MenuItem[])(int groupId, int itemId, int order, https://developer.android.com/reference/android/content/ComponentName caller, https://developer.android.com/reference/android/content/Intent specifics, https://developer.android.com/reference/android/content/Intent intent, int flags, https://developer.android.com/reference/android/view/MenuItem outSpecificItems) ` Add a group of menu items corresponding to actions that can be performed for a particular Intent. |
| ` abstract https://developer.android.com/reference/android/view/SubMenu` | ` https://developer.android.com/reference/android/view/Menu#addSubMenu(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence title) ` Add a new sub-menu to the menu. |
| ` abstract https://developer.android.com/reference/android/view/SubMenu` | ` https://developer.android.com/reference/android/view/Menu#addSubMenu(int,%20int,%20int,%20int)(int groupId, int itemId, int order, int titleRes) ` Variation on `https://developer.android.com/reference/android/view/Menu#addSubMenu(int,%20int,%20int,%20java.lang.CharSequence)` that takes a string resource identifier for the title instead of the string itself. |
| ` abstract https://developer.android.com/reference/android/view/SubMenu` | ` https://developer.android.com/reference/android/view/Menu#addSubMenu(int,%20int,%20int,%20java.lang.CharSequence)(int groupId, int itemId, int order, https://developer.android.com/reference/java/lang/CharSequence title) ` Add a new sub-menu to the menu. |
| ` abstract https://developer.android.com/reference/android/view/SubMenu` | ` https://developer.android.com/reference/android/view/Menu#addSubMenu(int)(int titleRes) ` Add a new sub-menu to the menu. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/Menu#clear()() ` Remove all existing items from the menu, leaving it empty as if it had just been created. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/Menu#close()() ` Closes the menu, if open. |
| ` abstract https://developer.android.com/reference/android/view/MenuItem` | ` https://developer.android.com/reference/android/view/Menu#findItem(int)(int id) ` Return the menu item with a particular identifier. |
| ` abstract https://developer.android.com/reference/android/view/MenuItem` | ` https://developer.android.com/reference/android/view/Menu#getItem(int)(int index) ` Gets the menu item at the given index. |
| ` abstract boolean` | ` https://developer.android.com/reference/android/view/Menu#hasVisibleItems()() ` Return whether the menu currently has item items that are visible. |
| ` abstract boolean` | ` https://developer.android.com/reference/android/view/Menu#isShortcutKey(int,%20android.view.KeyEvent)(int keyCode, https://developer.android.com/reference/android/view/KeyEvent event) ` Is a keypress one of the defined shortcut keys for this window. |
| ` abstract boolean` | ` https://developer.android.com/reference/android/view/Menu#performIdentifierAction(int,%20int)(int id, int flags) ` Execute the menu item action associated with the given menu identifier. |
| ` abstract boolean` | ` https://developer.android.com/reference/android/view/Menu#performShortcut(int,%20android.view.KeyEvent,%20int)(int keyCode, https://developer.android.com/reference/android/view/KeyEvent event, int flags) ` Execute the menu item action associated with the given shortcut character. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/Menu#removeGroup(int)(int groupId) ` Remove all items in the given group. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/Menu#removeItem(int)(int id) ` Remove the item with the given identifier. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/Menu#setGroupCheckable(int,%20boolean,%20boolean)(int group, boolean checkable, boolean exclusive) ` Control whether a particular group of items can show a check mark. |
| ` default void` | ` https://developer.android.com/reference/android/view/Menu#setGroupDividerEnabled(boolean)(boolean groupDividerEnabled) ` Enable or disable the group dividers. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/Menu#setGroupEnabled(int,%20boolean)(int group, boolean enabled) ` Enable or disable all menu items that are in the given group. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/Menu#setGroupVisible(int,%20boolean)(int group, boolean visible) ` Show or hide all menu items that are in the given group. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/Menu#setQwertyMode(boolean)(boolean isQwerty) ` Control whether the menu should be running in qwerty mode (alphabetic shortcuts) or 12-key mode (numeric shortcuts). |
| ` abstract int` | ` https://developer.android.com/reference/android/view/Menu#size()() ` Get the number of items in the menu. |

## Constants

### CATEGORY_ALTERNATIVE

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int CATEGORY_ALTERNATIVE
```

Category code for the order integer for items/groups that are alternative actions on the data that is currently displayed -- or/add this with your base value.

<br />

Constant Value: 262144 (0x00040000)

### CATEGORY_CONTAINER

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int CATEGORY_CONTAINER
```

Category code for the order integer for items/groups that are part of a container -- or/add this with your base value.

<br />

Constant Value: 65536 (0x00010000)

### CATEGORY_SECONDARY

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int CATEGORY_SECONDARY
```

Category code for the order integer for items/groups that are user-supplied secondary (infrequently used) options -- or/add this with your base value.

<br />

Constant Value: 196608 (0x00030000)

### CATEGORY_SYSTEM

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int CATEGORY_SYSTEM
```

Category code for the order integer for items/groups that are provided by the system -- or/add this with your base value.

<br />

Constant Value: 131072 (0x00020000)

### FIRST

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int FIRST
```

First value for group and item identifier integers.

<br />

Constant Value: 1 (0x00000001)

### FLAG_ALWAYS_PERFORM_CLOSE

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int FLAG_ALWAYS_PERFORM_CLOSE
```

Flag for `https://developer.android.com/reference/android/view/Menu#performShortcut(int,%20android.view.KeyEvent,%20int)`: if set, always close the menu after executing the shortcut. Closing the menu also resets the prepared state.

<br />

Constant Value: 2 (0x00000002)

### FLAG_APPEND_TO_GROUP

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int FLAG_APPEND_TO_GROUP
```

Flag for `https://developer.android.com/reference/android/view/Menu#addIntentOptions(int,%20int,%20int,%20android.content.ComponentName,%20android.content.Intent[],%20android.content.Intent,%20int,%20android.view.MenuItem[])`: if set, do not automatically remove any existing menu items in the same group.

<br />

Constant Value: 1 (0x00000001)

### FLAG_PERFORM_NO_CLOSE

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int FLAG_PERFORM_NO_CLOSE
```

Flag for `https://developer.android.com/reference/android/view/Menu#performShortcut(int,%20android.view.KeyEvent,%20int)`: if set, do not close the menu after executing the shortcut.

<br />

Constant Value: 1 (0x00000001)

### NONE

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int NONE
```

Value to use for group and item identifier integers when you don't care about them.

<br />

Constant Value: 0 (0x00000000)

### SUPPORTED_MODIFIERS_MASK

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SUPPORTED_MODIFIERS_MASK
```

A mask of all supported modifiers for MenuItem's keyboard shortcuts

<br />

Constant Value: 69647 (0x0001100f)

## Public methods

### add

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract MenuItem add (int groupId, 
                int itemId, 
                int order, 
                CharSequence title)
```

Add a new item to the menu. This item displays the given title for its label.

<br />

| Parameters ||
|---|---|
| `groupId` | `int`: The group identifier that this item should be part of. This can be used to define groups of items for batch state changes. Normally use `https://developer.android.com/reference/android/view/Menu#NONE` if an item should not be in a group. <br /> |
| `itemId` | `int`: Unique item ID. Use `https://developer.android.com/reference/android/view/Menu#NONE` if you do not need a unique ID. <br /> |
| `order` | `int`: The order for the item. Use `https://developer.android.com/reference/android/view/Menu#NONE` if you do not care about the order. See `https://developer.android.com/reference/android/view/MenuItem#getOrder()`. <br /> |
| `title` | `CharSequence`: The text to display for the item. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem` | The newly added menu item. <br /> |

### add

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract MenuItem add (int titleRes)
```

Add a new item to the menu. This item displays the given title for its label.

<br />

| Parameters ||
|---|---|
| `titleRes` | `int`: Resource identifier of title string. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem` | The newly added menu item. <br /> |

### add

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract MenuItem add (CharSequence title)
```

Add a new item to the menu. This item displays the given title for its label.

<br />

| Parameters ||
|---|---|
| `title` | `CharSequence`: The text to display for the item. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem` | The newly added menu item. <br /> |

### add

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract MenuItem add (int groupId, 
                int itemId, 
                int order, 
                int titleRes)
```

Variation on `https://developer.android.com/reference/android/view/Menu#add(int,%20int,%20int,%20java.lang.CharSequence)` that takes a string resource identifier instead of the string itself.

<br />

| Parameters ||
|---|---|
| `groupId` | `int`: The group identifier that this item should be part of. This can also be used to define groups of items for batch state changes. Normally use `https://developer.android.com/reference/android/view/Menu#NONE` if an item should not be in a group. <br /> |
| `itemId` | `int`: Unique item ID. Use `https://developer.android.com/reference/android/view/Menu#NONE` if you do not need a unique ID. <br /> |
| `order` | `int`: The order for the item. Use `https://developer.android.com/reference/android/view/Menu#NONE` if you do not care about the order. See `https://developer.android.com/reference/android/view/MenuItem#getOrder()`. <br /> |
| `titleRes` | `int`: Resource identifier of title string. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem` | The newly added menu item. <br /> |

### addIntentOptions

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract int addIntentOptions (int groupId, 
                int itemId, 
                int order, 
                ComponentName caller, 
                Intent[] specifics, 
                Intent intent, 
                int flags, 
                MenuItem[] outSpecificItems)
```

Add a group of menu items corresponding to actions that can be performed for a particular Intent. The Intent is most often configured with a null action, the data that the current activity is working with, and includes either the `https://developer.android.com/reference/android/content/Intent#CATEGORY_ALTERNATIVE` or `https://developer.android.com/reference/android/content/Intent#CATEGORY_SELECTED_ALTERNATIVE` to find activities that have said they would like to be included as optional action. You can, however, use any Intent you want.

See `https://developer.android.com/reference/android/content/pm/PackageManager#queryIntentActivityOptions(android.content.ComponentName,%20android.content.Intent[],%20android.content.Intent,%20int)` for more \* details on the <var translate="no">caller</var>, <var translate="no">specifics</var>, and <var translate="no">intent</var> arguments. The list returned by that function is used to populate the resulting menu items.

All of the menu items of possible options for the intent will be added with the given group and id. You can use the group to control ordering of the items in relation to other items in the menu. Normally this function will automatically remove any existing items in the menu in the same group and place a divider above and below the added items; this behavior can be modified with the <var translate="no">flags</var> parameter. For each of the generated items `https://developer.android.com/reference/android/view/MenuItem#setIntent(android.content.Intent)` is called to associate the appropriate Intent with the item; this means the activity will automatically be started for you without having to do anything else.

<br />

| Parameters ||
|---|---|
| `groupId` | `int`: The group identifier that the items should be part of. This can also be used to define groups of items for batch state changes. Normally use `https://developer.android.com/reference/android/view/Menu#NONE` if the items should not be in a group. <br /> |
| `itemId` | `int`: Unique item ID. Use `https://developer.android.com/reference/android/view/Menu#NONE` if you do not need a unique ID. <br /> |
| `order` | `int`: The order for the items. Use `https://developer.android.com/reference/android/view/Menu#NONE` if you do not care about the order. See `https://developer.android.com/reference/android/view/MenuItem#getOrder()`. <br /> |
| `caller` | `ComponentName`: The current activity component name as defined by queryIntentActivityOptions(). <br /> |
| `specifics` | `Intent`: Specific items to place first as defined by queryIntentActivityOptions(). <br /> |
| `intent` | `Intent`: Intent describing the kinds of items to populate in the list as defined by queryIntentActivityOptions(). <br /> |
| `flags` | `int`: Additional options controlling how the items are added. <br /> |
| `outSpecificItems` | `MenuItem`: Optional array in which to place the menu items that were generated for each of the <var translate="no">specifics</var> that were requested. Entries may be null if no activity was found for that specific action. <br /> |

| Returns ||
|---|---|
| `int` | The number of menu items that were added. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/Menu#FLAG_APPEND_TO_GROUP`
- `https://developer.android.com/reference/android/view/MenuItem#setIntent(android.content.Intent)`
- `https://developer.android.com/reference/android/content/pm/PackageManager#queryIntentActivityOptions(android.content.ComponentName,%20android.content.Intent[],%20android.content.Intent,%20int)`

### addSubMenu

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract SubMenu addSubMenu (CharSequence title)
```

Add a new sub-menu to the menu. This item displays the given title for its label. To modify other attributes on the submenu's menu item, use `https://developer.android.com/reference/android/view/SubMenu#getItem()`.

<br />

| Parameters ||
|---|---|
| `title` | `CharSequence`: The text to display for the item. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SubMenu` | The newly added sub-menu <br /> |

### addSubMenu

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract SubMenu addSubMenu (int groupId, 
                int itemId, 
                int order, 
                int titleRes)
```

Variation on `https://developer.android.com/reference/android/view/Menu#addSubMenu(int,%20int,%20int,%20java.lang.CharSequence)` that takes a string resource identifier for the title instead of the string itself.

<br />

| Parameters ||
|---|---|
| `groupId` | `int`: The group identifier that this item should be part of. This can also be used to define groups of items for batch state changes. Normally use `https://developer.android.com/reference/android/view/Menu#NONE` if an item should not be in a group. <br /> |
| `itemId` | `int`: Unique item ID. Use `https://developer.android.com/reference/android/view/Menu#NONE` if you do not need a unique ID. <br /> |
| `order` | `int`: The order for the item. Use `https://developer.android.com/reference/android/view/Menu#NONE` if you do not care about the order. See `https://developer.android.com/reference/android/view/MenuItem#getOrder()`. <br /> |
| `titleRes` | `int`: Resource identifier of title string. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SubMenu` | The newly added sub-menu <br /> |

### addSubMenu

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract SubMenu addSubMenu (int groupId, 
                int itemId, 
                int order, 
                CharSequence title)
```

Add a new sub-menu to the menu. This item displays the given <var translate="no">title</var> for its label. To modify other attributes on the submenu's menu item, use `https://developer.android.com/reference/android/view/SubMenu#getItem()`.

Note that you can only have one level of sub-menus, i.e. you cannnot add a subMenu to a subMenu: An `https://developer.android.com/reference/java/lang/UnsupportedOperationException` will be thrown if you try.

<br />

| Parameters ||
|---|---|
| `groupId` | `int`: The group identifier that this item should be part of. This can also be used to define groups of items for batch state changes. Normally use `https://developer.android.com/reference/android/view/Menu#NONE` if an item should not be in a group. <br /> |
| `itemId` | `int`: Unique item ID. Use `https://developer.android.com/reference/android/view/Menu#NONE` if you do not need a unique ID. <br /> |
| `order` | `int`: The order for the item. Use `https://developer.android.com/reference/android/view/Menu#NONE` if you do not care about the order. See `https://developer.android.com/reference/android/view/MenuItem#getOrder()`. <br /> |
| `title` | `CharSequence`: The text to display for the item. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SubMenu` | The newly added sub-menu <br /> |

### addSubMenu

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract SubMenu addSubMenu (int titleRes)
```

Add a new sub-menu to the menu. This item displays the given title for its label. To modify other attributes on the submenu's menu item, use `https://developer.android.com/reference/android/view/SubMenu#getItem()`.

<br />

| Parameters ||
|---|---|
| `titleRes` | `int`: Resource identifier of title string. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SubMenu` | The newly added sub-menu <br /> |

### clear

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void clear ()
```

Remove all existing items from the menu, leaving it empty as if it had just been created.

<br />

### close

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void close ()
```

Closes the menu, if open.

<br />

### findItem

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract MenuItem findItem (int id)
```

Return the menu item with a particular identifier.

<br />

| Parameters ||
|---|---|
| `id` | `int`: The identifier to find. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem` | The menu item object, or null if there is no item with this identifier. <br /> |

### getItem

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract MenuItem getItem (int index)
```

Gets the menu item at the given index.

<br />

| Parameters ||
|---|---|
| `index` | `int`: The index of the menu item to return. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/MenuItem` | The menu item. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | when `index < 0 || >= size()` |

### hasVisibleItems

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean hasVisibleItems ()
```

Return whether the menu currently has item items that are visible.

<br />

| Returns ||
|---|---|
| `boolean` | True if there is one or more item visible, else false. <br /> |

### isShortcutKey

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean isShortcutKey (int keyCode, 
                KeyEvent event)
```

Is a keypress one of the defined shortcut keys for this window.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: the key code from `https://developer.android.com/reference/android/view/KeyEvent` to check. <br /> |
| `event` | `KeyEvent`: the `https://developer.android.com/reference/android/view/KeyEvent` to use to help check. <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

### performIdentifierAction

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean performIdentifierAction (int id, 
                int flags)
```

Execute the menu item action associated with the given menu identifier.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier associated with the menu item. <br /> |
| `flags` | `int`: Additional option flags or 0. <br /> |

| Returns ||
|---|---|
| `boolean` | If the given identifier exists and is shown, returns true; else returns false. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/Menu#FLAG_PERFORM_NO_CLOSE`

### performShortcut

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean performShortcut (int keyCode, 
                KeyEvent event, 
                int flags)
```

Execute the menu item action associated with the given shortcut character.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: The keycode of the shortcut key. <br /> |
| `event` | `KeyEvent`: Key event message. <br /> |
| `flags` | `int`: Additional option flags or 0. <br /> |

| Returns ||
|---|---|
| `boolean` | If the given shortcut exists and is shown, returns true; else returns false. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/Menu#FLAG_PERFORM_NO_CLOSE`

### removeGroup

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void removeGroup (int groupId)
```

Remove all items in the given group.

<br />

| Parameters ||
|---|---|
| `groupId` | `int`: The group to be removed. If there are no items in this group, nothing happens. <br /> |

### removeItem

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void removeItem (int id)
```

Remove the item with the given identifier.

<br />

| Parameters ||
|---|---|
| `id` | `int`: The item to be removed. If there is no item with this identifier, nothing happens. <br /> |

### setGroupCheckable

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setGroupCheckable (int group, 
                boolean checkable, 
                boolean exclusive)
```

Control whether a particular group of items can show a check mark. This is similar to calling `https://developer.android.com/reference/android/view/MenuItem#setCheckable(boolean)` on all of the menu items with the given group identifier, but in addition you can control whether this group contains a mutually-exclusive set items. This should be called after the items of the group have been added to the menu.

<br />

| Parameters ||
|---|---|
| `group` | `int`: The group of items to operate on. <br /> |
| `checkable` | `boolean`: Set to true to allow a check mark, false to disallow. The default is false. <br /> |
| `exclusive` | `boolean`: If set to true, only one item in this group can be checked at a time; checking an item will automatically uncheck all others in the group. If set to false, each item can be checked independently of the others. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/MenuItem#setCheckable(boolean)`
- `https://developer.android.com/reference/android/view/MenuItem#setChecked(boolean)`

### setGroupDividerEnabled

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setGroupDividerEnabled (boolean groupDividerEnabled)
```

Enable or disable the group dividers.

<br />

| Parameters ||
|---|---|
| `groupDividerEnabled` | `boolean` <br /> |

### setGroupEnabled

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setGroupEnabled (int group, 
                boolean enabled)
```

Enable or disable all menu items that are in the given group.

<br />

| Parameters ||
|---|---|
| `group` | `int`: The group of items to operate on. <br /> |
| `enabled` | `boolean`: If true the items will be enabled, else they will be disabled. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/MenuItem#setEnabled(boolean)`

### setGroupVisible

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setGroupVisible (int group, 
                boolean visible)
```

Show or hide all menu items that are in the given group.

<br />

| Parameters ||
|---|---|
| `group` | `int`: The group of items to operate on. <br /> |
| `visible` | `boolean`: If true the items are visible, else they are hidden. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/MenuItem#setVisible(boolean)`

### setQwertyMode

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setQwertyMode (boolean isQwerty)
```

Control whether the menu should be running in qwerty mode (alphabetic shortcuts) or 12-key mode (numeric shortcuts).

<br />

| Parameters ||
|---|---|
| `isQwerty` | `boolean`: If true the menu will use alphabetic shortcuts; else it will use numeric shortcuts. <br /> |

### size

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract int size ()
```

Get the number of items in the menu. Note that this will change any times items are added or removed from the menu.

<br />

| Returns ||
|---|---|
| `int` | The item count. <br /> |