Required. This must be the root node. Contains <item> and/or
<group> elements.

attributes:

xmlns:android

XML namespace. Required. Defines the XML namespace, which
must be "http://schemas.android.com/apk/res/android".

<item>

A menu item. May contain a <menu> element (for a Sub
Menu). Must be a child of a <menu> or <group> element.

attributes:

android:id

Resource ID. A unique resource ID. To create a new resource ID for this item, use the form:
"@+id/name". The plus symbol indicates that this should be created as a new
ID.

android:title

String resource. The menu title as a string resource or raw string.

android:titleCondensed

String resource. A condensed title as a string resource or a raw string. This
title is used for situations in which the normal title is too long.

android:icon

Drawable resource. An image to be used as the menu item icon.

android:onClick

Method name. The method to call when this menu item is clicked. The
method must be declared in the activity as public and accept a MenuItem as its
only parameter, which indicates the item clicked. This method takes precedence over the standard
callback to onOptionsItemSelected(). See the
example at the bottom.

Warning: If you obfuscate your code using ProGuard (or a similar tool),
be sure to exclude the method you specify in this attribute from renaming, because it can break the
functionality.

Introduced in API Level 11.

android:showAsAction

Keyword. When and how this item should appear as an action item in the app
bar. A menu item can appear as an action item only when the activity includes an
app bar. Valid values:

Value

Description

ifRoom

Only place this item in the
app bar if there is room for it. If there is not room for all
the items marked "ifRoom", the items with the lowest
orderInCategory values are displayed as actions, and
the remaining items are displayed in the overflow menu.

withText

Also include the title text (defined
by android:title) with the action item. You can include this value along with one
of the others as a flag set, by separating them with a pipe |.

never

Never place this item in the app bar. Instead, list the item in the app bar's overflow
menu.

always

Always place this item in the app bar.
Avoid using this unless it's critical that the item always appear in the action
bar. Setting multiple items to always appear as action items can result in them overlapping
with other UI in the app bar.

collapseActionView

The action view associated
with this action item (as declared by android:actionLayout or
android:actionViewClass) is
collapsible.Introduced in API Level 14.

Warning: If you obfuscate your code using ProGuard (or a similar tool),
be sure to exclude the class you specify in this attribute from renaming, because it can break the
functionality.

Introduced in API Level 14.

android:alphabeticShortcut

Char. A character for the alphabetic shortcut key.

android:numericShortcut

Integer. A number for the numeric shortcut key.

android:alphabeticModifiers

Keyword. A modifier for the menu item's alphabetic
shortcut. The default value corresponds to the Control
key. Valid values:

Value

Description

META

Corresponds to the Meta meta key

CTRL

Corresponds to the Control meta key

ALT

Corresponds to the Alt meta key

SHIFT

Corresponds to the Shift meta key

SYM

Corresponds to the Sym meta key

FUNCTION

Corresponds to the Function meta key

Note: You can specify multiple keywords in an
attribute. For example,
android:alphabeticModifiers="CTRL|SHIFT" indicates
that to trigger the corresponding menu item, the user needs to
press both Control and Shift meta keys along
with the shortcut.

You can use the setAlphabeticShortcut() method to
set the attribute values programmatically. For more information
about the alphabeticModifier attribute, go to
alphabeticModifiers.

android:numericModifiers

Keyword. A modifier for the menu item's numeric shortcut.
The default value corresponds to the Control key. Valid
values:

Value

Description

META

Corresponds to the Meta meta key

CTRL

Corresponds to the Control meta key

ALT

Corresponds to the Alt meta key

SHIFT

Corresponds to the Shift meta key

SYM

Corresponds to the Sym meta key

FUNCTION

Corresponds to the Function meta key

Note: You can specify multiple keywords in an
attribute. For example,
android:numericModifiers="CTRL|SHIFT" indicates
that to trigger the corresponding menu item, the user needs to
press both Control and Shift meta keys along
with the shortcut.

You can use the setNumericShortcut() method to set
the attribute values programmatically. For more information about
the numericModifier attribute, go
to numericModifiers.