Another common use for menus is to switch certain functions on or off and often this has to be done in a mutually exclusive manner such as when only one possible selection can be made from a list. For this purpose Android provides a framework for defining checkboxes and radio buttons using groups of menu items.
The Eclipse IDE provides another, more intuitive way to construct XML menu files in the form of a graphical pane that can be accessed with the Layout tab of any Android XML file. Start up a new project and inside the res
folder, create a new folder called menu
.
Create a new Android XML file inside
res/menu
and call itmy_menu.xml
.View the new file through the Layout tab.
Using the controls provided (in particular the Add..., Up, and Down buttons) construct a menu as seen in the next screenshot. Give each item an
id
and atitle
. You will need to create the Group first:Give the menu group an
id
and set the Checkable behavior...