Android Support Preferences Library: nested PreferenceScreen
Android Support Library includes two librares to simplify the implementation of settings pages:
A post from Ian Lake on Google+ shows how to use them. It is easy, but when you need to use multiple nested settings pages you need to pay attention to a couple of points:
- You need to implement the onCreatePreferences method:
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
}
- Every PreferenceScreen in your preferences XML file must have a key:
<PreferenceScreen android:key="prefscrkey">
This key will not be used in any setting, but in the onCreatePreferences, in order to understand the screen to show.