Recently, I am very busy. I have been busy with projects of the Hangzhou Power Bureau and the wuxijiang hydropower plant, so I haven't updated my blog for a long time.
Play android in the evening and find it interesting to develop Android menus. Log on to the blog:
@ Override
PublicBoolean oncreateoptionsmenu (Android. View. menu ){
Menu. Add (0, 1, 0,"Start");
Menu. Add (0, 2, 0,"Cancel");
// Android. View. menu file = menu. addsubmenu (0, about, 0, "About Us ");
Submenu file = menu. addsubmenu (0, 3, 0,"About Us");
Menuinflater Inflater = getmenuinflater ();
Inflater. Inflate (R. Menu. Menu, file );
// Todo auto-generated method stub
Return True;
}
First, you need to rewrite the oncreateoptionsmenu method, that is, after the rewriting, the menu that comes with the mobile phone will appear according to your ideas ...... It's the same as not saying it.
The. Menu. Add (, 0, "START") that needs to be recorded here. The parameter meaning can be viewed directly.CodePrompt. The second parameter indicates the Itemid, which is unique. Because you need to obtain the menu
It must be used. Menu. Add adds a normal menu item.
The menu. addsubmenu below adds a special menu item, which has a sub menu item. This method returns a submenu object, because the submenu interface inherits
So it is okay to declare it as menu. Such as the line commented out in the Code.
The following describes how to load sub-menu items through an XML file. R. Menu. Menu is a file named menu. xml under the Res/menu directory. It contains sub-menu items.
Okay. One o'clock again.