The options menu is an Android user interface component that provides standardized menus to applications. The menus appear at the bottom of the screen when the user presses the Menu button on the device.
To add support for the options menu to an application, we need to do the following:
Create the menu.xml resource where we specify what the menu consists of.
onCreateOptionsMenu() to the activity that
should have this menu. This is where we inflate the menu.xml resource.
Provide handling of menu events in
We start by defining the menus in an XML resource for the options menu. Just like with other Android XML files, we can use the little a+ icon in the Eclipse toolbar or choose File→New…→Android XML to launch the New Android XML File dialog. In this dialog, enter “menu.xml” in the file field, and for Type, select Menu. Click the Finish button, and Eclipse will create a new folder called /res/menu that contains the menu.xml file and will open this file in the developer-friendly view (see Figure 7-3).
Figure 7-3. Menu.xml in developer-friendly view
In this view, you can click on Add→Item, which will add a new menu item to your menu. In the Attributes section on the right, you can see over a dozen attributes that we can set for this menu item. Just like before, not all attributes are equally important:
The unique identifier of this ...