Page Summary
-
MenuUtils provides extensions for Android Menu and related classes, added in API level XE12.
-
Key methods include
setDescriptionto add descriptive text to a MenuItem andsetInitialMenuItemto control which MenuItem is shown initially. -
Descriptions for MenuItems can only be set programmatically using the
setDescriptionmethods, not in XML. -
setInitialMenuItemallows specifying a preferred starting MenuItem in a menu layout, potentially changing the layout of other items.
A collection of extensions for Menu and related classes.
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| static void | |||||||||||
| static void |
setDescription(MenuItem item, int description)
|
||||||||||
| static void | |||||||||||
| Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods
public static void setDescription (MenuItem item, CharSequence description)
Sets an additional description text on a menu item.
The description attribute can only be set through this method. The attribute is not supported in XML.
Parameters
| item | the menu item |
|---|---|
| description | additional description text |
Throws
| RuntimeException | if item is not a concrete implementation |
|---|
public static void setDescription (MenuItem item, int description)
Sets an additional description text on a menu item.
The description attribute can only be set through this method. The attribute is not supported in XML.
Parameters
| item | the menu item |
|---|---|
| description | additional description text (as a resource ID) |
Throws
| RuntimeException | if item is not a concrete implementation |
|---|
public static void setInitialMenuItem (Menu menu, MenuItem item)
Sets the initial menu item when users open a menu.
By default, the first menu item appears with all the other items to the right. This method lets you set another menu item to initially show, and other items can potentially appear to the left or right of the item that is initially shown.
Parameters
| menu | the menu on which preferred initial menu item should be set |
|---|---|
| item | the preferred initial menu item. If this item cannot be found, the menu falls back to the default behavior |
Throws
| RuntimeException | if menu is not a concrete implementation |
|---|