Menus

The top-right area of the app bar is reserved for the app bar’s menu. The menu consists of action items (sometimes also referred to as menu items), which can perform an action on the current screen or on the app as a whole. You will add an action item to allow the user to create a new crime.

Your new action item will require a string resource for its label. Open res/values/strings.xml and add a string label describing your new action.

Listing 14.1  Adding a string for menu (res/values/strings.xml)

<resources>
    ...
    <string name="crime_solved_label">Solved</string>
    <string name="new_crime">New Crime</string>

</resources>

Defining a menu in XML

Menus are a type of resource, similar to layouts. You create an ...

Get Android Programming: The Big Nerd Ranch Guide, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.