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:
- Options Menu: The most general menu, Android call it option menu
- 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.
- Context Menu: The menu that appears after long press the view control in Android, Windows right-click popup menu that is context menu
- 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 .
- Select menu (Alternative menu): With less, later introduced separately, this article first skip (actually I have not figured out O (≧v≦) o~~)
- 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