Android UI menu

Source: Internet
Author: User

Android provides three menu types: Options menu, context menu, and sub menu.

The options menu is displayed by pressing the Home key. The context menu needs to be displayed after pressing the top 2 S button on The View. Both menus can be added to sub-menus. Sub-menus cannot be nested.

The options menu can display up to six menu options at the bottom of the screen. It becomes an icon menu, and the icon menu cannot have the checkable option. The more Icon menu will be used to call out the excess 6 to become the expanded menu. Options menu is generated by oncreateoptionsmenu of the activity. This function is called only when the menu is generated for the first time. Any idea of changing the Options menu can only be implemented in onprepareoptionsmenu. This function will be called before the menu is displayed. Onoptionsitemselected processes the selected menu items.

Context menu is bound to a specific view. In activity, registerforcontextmenu is used to register context menu for a view. Before the context menu is displayed, oncreatecontextmenu is called to generate the menu. Oncontextitemselected: The selected menu item.

Android also provides the function of grouping menu items. You can divide menu items with similar functions into the same group. In this way, you can set menu properties by calling setgroupcheckable, setgroupenabled, and setgroupvisible, you do not need to set it separately.

Related Article

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.