8.4.9. Defining the Fragments’ Menus

You’ll now use the techniques you learned in Section 7.3.4 to create two menu resource files in the app’s res/menu folder:

fragment_contact_list_menu.xml defines the menu item for adding a contact.

fragment_details_menu.xml defines the menu items for editing an existing contact and deleting a contact.

When both the ContactListFragment and the DetailsFragment are displayed on a tablet at the same time, all of the menu items are displayed.

Figures 8.128.13 show the settings for the menu items in the two menu resource files. Each menu item’s Order in category values determines the order in which the menu items appear on the action bar. For each menu item’s Icon value, we specified a standard Android icon. ...

Get Android™ How to Program, Second 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.