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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.