diff --git a/docs/html/guide/topics/resources/menu-resource.jd b/docs/html/guide/topics/resources/menu-resource.jd index cde72bdf37dbe..7bcd78a5196d6 100644 --- a/docs/html/guide/topics/resources/menu-resource.jd +++ b/docs/html/guide/topics/resources/menu-resource.jd @@ -36,22 +36,23 @@ In XML: @[package:]menu.filename <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@[+][package:]id/resource_name" - android:menuCategory=["container" | "system" | "secondary" | "alternative"] - android:orderInCategory="integer" android:title="string" android:titleCondensed="string" android:icon="@[package:]drawable/drawable_resource_name" + android:showAsAction=["ifRoom" | "never" | "withText" | "always"] android:alphabeticShortcut="string" android:numericShortcut="string" android:checkable=["true" | "false"] android:visible=["visible" | "invisible" | "gone"] - android:enabled=["enabled" | "disabled"] /> + android:enabled=["enabled" | "disabled"] + android:menuCategory=["container" | "system" | "secondary" | "alternative"] + android:orderInCategory="integer" /> <group android:id="@[+][package:]id/resource name" - android:menuCategory=["container" | "system" | "secondary" | "alternative"] - android:orderInCategory="integer" android:checkableBehavior=["none" | "all" | "single"] android:visible=["visible" | "invisible" | "gone"] - android:enabled=["enabled" | "disabled"] > + android:enabled=["enabled" | "disabled"] + android:menuCategory=["container" | "system" | "secondary" | "alternative"] + android:orderInCategory="integer" > <item /> </group> <item > @@ -77,47 +78,7 @@ In XML: @[package:]menu.filename "http://schemas.android.com/apk/res/android". -
<group>
-
A menu group (to create a collection of items that share traits, such as whether they are -visible, enabled, or checkable). Contains one or more <item> elements. Must be a -child of a <menu> 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:menuCategory
-
Keyword. Value corresponding to {@link android.view.Menu} {@code CATEGORY_*} - constants, which define the group's priority. Valid values: - - - - - - -
ValueDescription
containerFor groups that are part of a -container.
systemFor groups that are provided by the -system.
secondaryFor groups that are user-supplied secondary -(infrequently used) options.
alternativeFor groups that are alternative actions -on the data that is currently displayed.
-
-
android:orderInCategory
-
Integer. The default order of the items within the category.
-
android:checkableBehavior
-
Keyword. The type of checkable behavior for the group. Valid values: - - - - - -
ValueDescription
noneNot checkable
allAll items can be checked (use checkboxes)
singleOnly one item can be checked (use radio buttons)
-
-
android:visible
-
Boolean. "true" if the group is visible.
-
android:enabled
-
Boolean. "true" if the group is enabled.
-
-
+
<item>
A menu item. May contain a <menu> element (for a Sub Menu). Must be a child of a <menu> or <group> element. @@ -125,7 +86,50 @@ on the data that is currently displayed.
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.
+"@+id/name". The plus symbol indicates that this should be created as a new +ID.
+
android:title
+
String. The menu title.
+
android:titleCondensed
+
String. A condensed title, 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:showAsAction
+
Keyword. When and how this item should appear as an action item in the Action +Bar. A menu item can appear as an action item only when the activity includes an {@link +android.app.ActionBar} (introduced in API Level HONEYCOMB). Valid values: + + + + + + +
ValueDescription
ifRoomOnly place this item in the Action Bar if +there is room for it.
withTextAlso include the title text (defined +by {@code 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 {@code |}.
neverNever place this item in the Action Bar.
alwaysAlways place this item in the Action 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 action bar.
+

See Using the Action Bar for +more information.

+

Introduced in API Level HONEYCOMB.

+
+ +
android:alphabeticShortcut
+
Char. A character for the alphabetic shortcut key.
+
android:numericShortcut
+
Integer. A number for the numeric shortcut key.
+
android:checkable
+
Boolean. "true" if the item is checkable.
+
android:checked
+
Boolean. "true" if the item is checked by default.
+
android:visible
+
Boolean. "true" if the item is visible by default.
+
android:enabled
+
Boolean. "true" if the item is enabled by default.
android:menuCategory
Keyword. Value corresponding to {@link android.view.Menu} {@code CATEGORY_*} constants, which define the item's priority. Valid values: @@ -143,25 +147,51 @@ on the data that is currently displayed.
android:orderInCategory
Integer. The order of "importance" of the item, within a group.
-
android:title
-
String. The menu title.
-
android:titleCondensed
-
String. A condensed title, 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:alphabeticShortcut
-
Char. A character for the alphabetic shortcut key.
-
android:numericShortcut
-
Integer. A number for the numeric shortcut key.
-
android:checkable
-
Boolean. "true" if the item is checkable.
-
android:checked
-
Boolean. "true" if the item is checked by default.
+ + + +
<group>
+
A menu group (to create a collection of items that share traits, such as whether they are +visible, enabled, or checkable). Contains one or more <item> elements. Must be a +child of a <menu> 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:checkableBehavior
+
Keyword. The type of checkable behavior for the group. Valid values: + + + + + +
ValueDescription
noneNot checkable
allAll items can be checked (use checkboxes)
singleOnly one item can be checked (use radio +buttons)
+
android:visible
-
Boolean. "true" if the item is visible by default.
+
Boolean. "true" if the group is visible.
android:enabled
-
Boolean. "true" if the item is enabled by default.
+
Boolean. "true" if the group is enabled.
+
android:menuCategory
+
Keyword. Value corresponding to {@link android.view.Menu} {@code CATEGORY_*} + constants, which define the group's priority. Valid values: + + + + + + +
ValueDescription
containerFor groups that are part of a +container.
systemFor groups that are provided by the +system.
secondaryFor groups that are user-supplied secondary +(infrequently used) options.
alternativeFor groups that are alternative actions +on the data that is currently displayed.
+
+
android:orderInCategory
+
Integer. The default order of the items within the category.
@@ -174,7 +204,8 @@ too long. <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/item1" android:title="@string/item1" - android:icon="@drawable/group_item1_icon" /> + android:icon="@drawable/group_item1_icon" + android:showAsAction="ifRoom|withText"/> <group android:id="@+id/group"> <item android:id="@+id/group_item1" android:title="@string/group_item1" @@ -184,7 +215,8 @@ too long. android:icon="@drawable/group_item2_icon" /> </group> <item android:id="@+id/submenu" - android:title="@string/submenu_title" > + android:title="@string/submenu_title" + android:showAsAction="ifRoom|withText" > <menu> <item android:id="@+id/submenu_item1" android:title="@string/submenu_item1" /> @@ -201,6 +233,8 @@ public boolean onCreateOptionsMenu(Menu menu) { return true; } +

Note: The {@code android:showAsAction} attribute is +available only on Android X.X (API Level HONEYCOMB) and greater.