Files in RES/menu

Source: Internet
Author: User

The menu resource file must be placed in the Res/menu directory. The <menu> label must be used as the root node in the menu resource file. In addition to the <menu> label, there are two other labels used to set menu items and groups. These two labels are <item> and <group>.

<Menu> A tag does not have any attributes, but can be nested in the <item> tag to indicate the sub-menu format. However, the <item> label cannot be embedded in the <item> label.

  <Item> the attributes of a tag are described as follows:

ID: Resource ID of the menu item
Menucategory: the type of a single dish. This attribute can have four values: container, system, secondary, and alternative. You can use the menucategroy attribute to control the position of menu items. For example, if the attribute is set to system, it indicates that the menu item is a system menu item and should be placed behind another menu item.

Orderincategor: sorting order of menus of the same type. This attribute requires an integer. For example, the values of menucategory are all three menu items (Item1, item2, and item3) of system ). Set the orderincategory attribute values of the three menu items to 3, 2, and 1. item3 is displayed at the beginning, and Item1 is displayed at the end.

Title: menu item title (Text displayed in the menu item)

Titlecondensed: short title of the menu item. This attribute value is displayed when the menu item title is too long.

Icon: Resource ID of the menu item icon

Alphabeticshortcut: letter shortcut for menu items

Numericshortcut: Numeric shortcut for menu items

Checkable: indicates whether the menu item has a check box. This attribute can be designed to be true or false.

Checked: If the menu item contains a check box (the checkable attribute is true), this attribute indicates whether the default status of the check box is selected. The configurable values are true or false.

Visible: whether the default menu item status is visible

Enable: whether the menu item is activated by default.

  <Group> the attributes of a tag are described as follows:

ID: ID of the menu Group

Menucategory: it has the same meaning as the attribute of the <item> tag with the same name. Only menu group with scope

Orderincategory: it has the same meaning as the attribute of the <item> label with the same name. Only menu group with scope

Checkablebehavior: Set the Selection Component (checkbox or radio button) displayed on all menu items of the group ). If this attribute value is set to all, the checkbox component is displayed. If it is set to single, the radio button component is displayed. If it is set to none, the normal menu items are displayed (no selected components are displayed ). It should be noted that the official Android SDK documentation has an incorrect description of this attribute. The original Article is: whether the items are checkable. Valid values: none,All (exclusive/radio buttons), single (non-exclusive/checkboxes)On the contrary, it should be trueAll (Non-exclusive/checkboxes), Single (Exclusive/radio buttons).

Visible: Indicates whether all menu items in the current group are displayed. The value that can be set for this attribute is true or false.

Enable: Indicates whether all menu items in the current group are activated. The value that can be set for this attribute is true or false.

 

<Menu xmlns: Android = "http://schemas.android.com/apk/res/android">

<Item Android: Id = ""/>

<Group Android: Id = "">

<Item/>

<Item/>

</Group>

<Item>

<Menu>

</Menu>

</Item>

</Menu>

* Used in code, for example:

Public boolen oncreateoptionsmenu (menu ){

Menuinflate = getmenuinflate ();

Menuinflate. Inflate (R. Menu. option_menu, menu );

Return true;

}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.