# Menus
[Menus](https://material.io/components/menus) display a list of choices on
temporary surfaces.

**Contents**
* [Design & API Documentation](#design-api-documentation)
* [Using menus](#using-menus)
* [Dropdown menus](#dropdown-menus)
* [Exposed dropdown menus](#exposed-dropdown-menus)
* [Theming](#theming-menus)
## Design & API Documentation
* [Google Material3 Spec](https://material.io/components/menus/overview)
* [API reference](https://developer.android.com/reference/android/view/Menu)
## Using menus
A menu displays a list of choices on a temporary surface. They appear when users
interact with a button, action, or other control.
Before you can use Material menus, you need to add a dependency to the Material
Components for Android library. For more information, go to the
[Getting started](https://github.com/material-components/material-components-android/tree/master/docs/getting-started.md)
page.
A typical menu resource looks like this:
```xml
```
A typical exposed dropdown menu looks like this:
```xml
```
See the [dropdown menus](#dropdown-menus) and
[exposed dropdown menus](#exposed-dropdown-menus) sections for detailed usage
information.
### Making menus accessible
Menus are readable by most screen readers, such as TalkBack. Text rendered in
menus is automatically provided to accessibility services. Additional content
labels are usually unnecessary.
Android's exposed dropdown menu component APIs support both label text and
helper text, which tell the user what information is requested for a menu. While
optional, their use is strongly encouraged. For more information about this
component's accessibility, check out
[the text field's a11y section](TextField.md#making-text-fields-accessible).
### Types
Menus allow users to make a selection from multiple options. They are less
prominent and take up less space than selection controls, such as a set of radio
buttons.
There are two types of menus: 1\. [Dropdown menus](#dropdown-menus) (overflow,
context, popup, and list popup window menus), 2\.
[Exposed dropdown menus](#exposed-dropdown-menus).

## Dropdown menus
Dropdown menus display a list of options, triggered by an icon, button, or
action. Their placement varies based on the element that opens them.
API and source code:
* `Menu`
* [Class definition](https://developer.android.com/reference/android/view/Menu)
* `MenuInflater`
* [Class definition](https://developer.android.com/reference/android/view/MenuInflater)
* `ContextMenu`
* [Class definition](https://developer.android.com/reference/android/view/ContextMenu)
* `PopupMenu`
* [Class definition](https://developer.android.com/reference/android/widget/PopupMenu)
* `ListPopupWindow`
* [Class definition](https://developer.android.com/reference/android/widget/ListPopupWindow)
### Dropdown menu examples
#### Overflow menus
The following example shows an overflow menu.

In code:
```kt
override fun onCreateOptionsMenu(menu: Menu): Boolean {
val inflater: MenuInflater = menuInflater
inflater.inflate(R.menu.overflow_menu, menu)
return true
}
```
In `res/menu/overflow_menu.xml`:
```xml
```
#### Context menus
The following example shows a context menu that appears when a `TextView` is
pressed for a designated amount of time.

In code:
```kt
override fun onCreate(savedInstanceState: Bundle?) {
...
val contextMenuTextView = view.findViewById(R.id.context_menu_tv)
// Register context menu for TextView
registerForContextMenu(contextMenuTextView)
}
override fun onCreateContextMenu(menu: ContextMenu, v: View, menuInfo: ContextMenu.ContextMenuInfo?) {
val contextMenuTextView = v as TextView
val context = context
// Add menu items via menu.add
menu.add(R.string.option_1)
.setOnMenuItemClickListener { item: MenuItem? ->
// Respond to item click.
}
menu.add(R.string.option_2)
.setOnMenuItemClickListener { item: MenuItem? ->
// Respond to item click.
}
}
override fun onContextMenuClosed(menu: Menu) {
// Respond to context menu being closed.
}
```
In the layout:
```xml
```
Alternatively, you can inflate a context menu in `onCreateContextMenu` (as with
the overflow menu):
```kt
override fun onCreateContextMenu(menu: ContextMenu, v: View, menuInfo: ContextMenu.ContextMenuInfo?) {
super.onCreateContextMenu(menu, v, menuInfo)
val inflater: MenuInflater = menuInflater
inflater.inflate(R.menu.context_menu, menu)
}
// Then, to handle clicks:
override fun onContextItemSelected(item: MenuItem): Boolean {
val info = item.menuInfo as AdapterView.AdapterContextMenuInfo
return when (item.itemId) {
R.id.option_1 -> {
// Respond to context menu item 1 click.
true
}
R.id.option_2 -> {
// Respond to context menu item 2 click.
true
}
else -> super.onContextItemSelected(item)
}
}
```
with a `res/menu/context_menu.xml`:
```xml
```
#### Popup menus
The following example shows a popup menu that displays when a button is clicked.

In code:
```kt
override fun onCreate(savedInstanceState: Bundle?) {
...
val button = view.findViewById