July 2015
Beginner to intermediate
600 pages
18h 59m
English
In this section, you will use what you have learned about menu resources to add an action item that lets users show and hide the subtitle of CrimeListActivity’s toolbar.
In res/menu/fragment_crime_list.xml, add an action item that will read Show Subtitle and will appear in the toolbar if there is room.
Listing 13.14 Adding Show Subtitle action item (res/menu/fragment_crime_list.xml)
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_item_new_crime"
android:icon="@android:drawable/ic_menu_add"
android:title="@string/new_crime"
app:showAsAction="ifRoom|withText"/>
<item ...Read now
Unlock full access