January 2014
Intermediate to advanced
736 pages
70h 43m
English
The DetailsFragment’s menu provides options for editing the current contact and for deleting it. Method onCreateOptionsMenu (Fig. 8.48, lines 114–119) inflates the menu resource file fragment_details_menu.xml. Method onOptionsItemSelected (lines 122– 146) uses the selected MenuItem’s resource ID to determine which one was selected. If the user selected the menu item with ID R.id.action_edit, lines 129–137 create a Bundle containing the contact’s data, then line 138 passes the Bundle to the DetailsFragmentListener for use in the AddEditFragment. If the user selected the menu item with ID R.id.action_delete, line 141 calls method deleteContact (Fig. 8.50).
Read now
Unlock full access