What's Your Preference?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
We also need to update AndroidManifest.xml to reference this activity, so we
can launch it later:

package="apt.tutorial"
android:versionCode="1"
android:versionName="1.0">

android:label="@string/app_name">











Step #3: Connect the Preference Activity to the Option
Menu
Now, we can add a menu option to launch the EditPreferences activity.
We need to add another to our LunchList/res/menu/option.xml file:


android:title="Add"
android:icon="@drawable/ic_menu_add"
/>
android:title="Settings"
android:icon="@drawable/ic_menu_preferences"
137
Subscribe to updates at http://commonsware.com
Special Creative Commons BY-NC-SA 3.0 License Edition
Précédent

- 170/447

Suivant