January 2017
Beginner to intermediate
624 pages
22h 42m
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 a subtitle displaying the number of crimes from 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. (The all-caps formatting is courtesy of the toolbar’s inherent styles; you have seen similar formatting on buttons.)
Listing 13.12 Adding SHOW SUBTITLE action item (res/menu/fragment_crime_list.xml)
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/new_crime" android:icon="@android:drawable/ic_menu_add" ...
Read now
Unlock full access