O'Reilly logo

Android Programming: The Big Nerd Ranch Guide by Brian Hardy, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required