Code the Page’s Behavior

The settings activity’s function is relatively simple. When a user presses one of the choices, that value is stored as a key/value pair in SharedPreferences. When the page is accessed, the activity reads the stored preferences and sets the RadioButtons to the stored value. The value stored in a SharedPreferences is used in ContactListActivity to sort the list of saved contacts.

Open the ContactSettingsActivity.java file and complete the following steps:

1. Copy the ImageButton initialization methods from the ContactActivity.java to the ContactSettingsActivity.java file so that the navigation bar will work. These methods are initMapButton(), initListButton(), and initSettingsButton(). Paste this code before the last

Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android 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.