Menu Options and XML
Inside the item and group elements you can specify various options, matching up with corresponding methods on or .
Title
The title of a menu item is provided via the attribute on an item element. This can be either a literal string or a reference to a string resource (e.g., ).
Icon
Menu items can have icons. To provide an icon – in the form of a reference to a drawable resource (e.g., ), use the attribute on the item element.
Order
By default, the order of the items in the menu is determined by the order they appear in the menu XML. If you want, you can change that default by specifying the attribute on the element. This is a 0‑based index of the order for the items associated with the current category. There is an implicit default category; groups can provide an attribute to specify a different category to use for items in that group.
Generally, though, it is simplest just to put the items in the XML in the order you want them to appear.
Enabled
Items and groups can be enabled or disabled, controlled in the XML via the attribute on the item or group element. By default, items and groups are enabled. Disabled items and groups appear in the menu but cannot be selected. You can change an item’s status at runtime via the method on , or change a group’s status via on .
Дата добавления: 2015-05-16; просмотров: 994;