ContactListFragment Overridden Methods onCreateOptionsMenu and onOptionsItemSelected

Method onCreateOptionsMenu (Fig. 8.32, lines 133–138) uses its MenuInflater argument to create the menu from fragment_contact_list_menu.xml, which contains the definition of the add (Image) menu item. If the user touches that MenuItem, method onOptionsItemSelected (lines 141–152) calls listener’s onAddContact method to notify the MainActivity that the user wants to add a new contact. MainActivity then displays the AddEditFragment (Section 8.7).

132      // display this fragment's menu items133      @Override134      public void onCreateOptionsMenu(Menu ...

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.