Http://www.cnblogs.com/Mrs-cc/archive/2012/07/21/2603042.html
1.OptionsMenu (Option menu) Usage SummaryHow to use:method One: Add menu item: Oncreateoptionsmenu (Menu menu) Add Menu.add (menu.none,menu.first+1,5, "delete"). SetIcon ()------> Add a Selection menu Single event: Switch (Item.getitemid ()) in onoptionsitemselected (MenuItem item), then add corresponding selection event------> Add Close Menu Thing Pieces: onoptionsmenuclosed (Menu menu), where you add code to--------> Add the Prepare menu (the event before the menu display), where you can add codemethod Two: Add the style of the menu: Create a menu directory in res, establish Xml,<menu><item id&&icom.etc></item></menu>---- ---> Oncreateoptionsmenu (this.getmenuinflater () inflate (R.menu.options_menu,menu) in the menu menu.function Description: the four parameters of the Add () method are, in turn:1, groups, if not grouped, then write Menu.none,2, ID, this is very important, Android based on this ID to determine the different menu3, order, the menu is now in front by the size of this parameter, from 1 to 61 times is the same as down, from left to right row. 4. Text, menu display textSetIcon (picture path): Set icon for menugetmenuinflater (). Inflate (R.menu.options_menu,menu):The role of A.inflate is to find out a layout that is defined by XML, but only to find out. B. The first parameter is the layout, and the second parameter is the menu. 2.
ContextMenu context Menu inherit from menu. Unlike the Options menu, the Options menu serves activity, and two context menus are registered on a View object. And the context menu needs to be registered, otherwise it cannot be displayed. The last context menu cannot add icons and shortcut keys. Order of Use: Add the style of the menu: Create the Menus directory in res, set up Xml,<menu><item id&&icom.etc></item></menu> Each context submenu corresponds to an XML-------> Register: Registerforcontextmenu (Control) is used in OnCreate (),--------->oncreateoptionsmenu (menu menu), create a menuinflater, using if to determine which control the incoming view is in, which triggers the style of the menu that the control gets: Inflater.inflate (style, menu);
3. Submenu submenuOrder of Use:1. Oncreateoptionsmenu () method covering activity, call menu's Addsubmenu () method to add submenu2. Call the Add () method of submenu, adding a submenu3. Set the title and title picture with Submenu.setheadericon (), and Submenu.setheadtitle (). 3. Override the Oncontextitemselected () method to respond to the Click event of the submenu
menu of Android controls