An Alternative Menu Item

In this section, you will use what you have learned about menus, compatibility, and alternative resources to add a menu item that lets users show and hide the subtitle of CrimeListActivity’s action bar.

Creating an alternative menu file

A menu item that applies the action bar should not be visible to users without an action bar. So the first step is to create an alternative menu resource. Create a menu-v11 folder in your project’s res directory. Then copy and paste fragment_crime_list.xml into this folder.

In res/menu-v11/fragment_crime_list.xml, add a menu item that will read Show Subtitle and will appear on the action bar if there is room.

Listing 16.14  Adding Show Subtitle menu item (res/menu-v11/fragment_crime_list.xml ...

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

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