In Menu.add () there are four parameters, beginning to understand its rationale. Read the PostScript here for inspection.
The use of "menus" is indispensable for any software. Under Android, each activity is bundled with a menu, and to define and use the menus, it must be done under activity, using both the Oncreateoptionsmenu and onoptionsitemselected methods. Examples are as follows:
Java code:
@Override
public boolean Oncreateoptionsmenu (Menu menu) {
Method of the base class to bring up the system menu (if any)
Super.oncreateoptionsmenu (menu);
Menu.add (0,1,0, "Start Again"). SetIcon (R.drawable.reflash);
Menu.add (0,2,0, "game Guide"). SetIcon (R.DRAWABLE.HELP);
Menu.add (0,3,0, "about the game"). SetIcon (R.drawable.info);
Menu.add (0,4,0, "Don't Want to Play"). SetIcon (R.drawable.exit);
If the icon is not displayed , change to Menu.add (0,3,0, "about Game");
The return value is "true", indicating that the menu is visible, that is, the menu is displayed
return true;
}
Take a look at the parameters of the Menu.add method:
The group ID parameter of the first int type, which represents the concept of groups, allows you to group several menu items into groups to better manage your menu buttons in a group way.
The item ID parameter of the second int type, which represents the project number. This parameter is important, and an item ID corresponds to an option in the menu. Use this item ID to determine which option you are using when using the menu later.
The order ID parameter of the third int type, which represents the order in which the menu items are displayed. The default is 0, which means that the order in which the menus are displayed is displayed in the order in which they appear.
The title parameter of the fourth string type, which represents the text displayed in the option.