Android Menu Details (a)--Understanding the menu in Android

Source: Internet
Author: User

Objective

Today saw the pro Android 3 menu in this chapter, the whole Android menu system has a further understanding, so take notes to share with you.

PS: Highly recommended "Pro Android 3", is the best I have seen so far the Android book, the Chinese version of "Proficient Android 2."

Understanding the Android Menu

Menus are an integral part of many applications, especially in Android, where all Android-powered phones even have a "menu" key, which shows the specifics of menus in Android programs. The following menus are available from the Android SDK:

    1. Options Menu: The most general menu, Android call it option menu
    2. submenu: Clicking on the submenu in Android will pop up the hover window to display the submenu item. The submenu does not support nesting , which means that no more submenus can be included in the sub-menu.
    3. Context Menu: The menu that appears after long press the view control in Android, Windows right-click popup menu that is context menu
    4. Icon Menu: This is relatively simple, is a menu item with icon, it is necessary to note that the submenu items, context menu items, extended menu items cannot display the icon .
    5. Select menu (Alternative menu): With less, later introduced separately, this article first skip (actually I have not figured out O (≧v≦) o~~)
    6. Extended Menu: The Options menu can only display 6 menu items, more than 6, the 6th menu item will be replaced by a system called "more" sub-menu, the original display items are not displayed as a submenu item in the "More" menu. Such as:

The 6th menu item automatically changes to "more" click "More" to show other menu items

ANDROID3.0 also introduced a call Action bar, this article does not explain, we own Google.

The Android.view.Menu interface represents a menu that Android uses to manage various menu items. Note that we generally do not create the menu ourselves, because each activity has its own default, and what we do is to add a menu item to it and respond to the Click event of the menu item . Android.view.MenuItem represents each menu item and Android.view.SubMenu represents a submenu. The relationship between the three can be used to denote

  

As mentioned above, each activity contains a menu, a menu can contain multiple menu items and multiple submenus, the submenu is actually a menu (because it implements the menu interface), so the submenu can also contain multiple menu items. submenu inherits the menu's Addsubmenu () method, but it throws a run-time error when it is called. Oncreateoptionsmenu () and onoptionsmenuselected () are two callback methods available in activity that create a click of a menu item and respond to a menu item.

Next "Android Menu details (ii)--Create and respond to menus" will show you how to use code to create menu items, to Group menu items, and various ways to respond to menu events.

Http://www.cnblogs.com/codingmyworld/archive/2011/08/21/2147829.html

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.