Preferences Flashcards
a Java class implements ?? for understanding the changes in the shared preferences
OnSharedPreferenceChangeListener
How should we add an edit text preferences:
//in setSummary if (preference instanceof EditTextPreference) { // For EditTextPreferences, set the summary to the value's simple string representation. preference.setSummary(value); }
We wanna make a list preference! What should we add in the XML resource file?
entries, entryValues
for example:
Add a res->values->arrays.xml file which contains two arrays, one for
labels and one for values. The arrays should contain strings found in this file–>
What kinda theme should we add for adding preference?
preferenceTheme added to styles.XML like this:
@style/PreferenceThemeOverlay
Can we find a preference by Key?
Yes we do!
Preference preference = findPreference(key);
How do you register a SharedPreferenceChangedListener? What do you Register it to?
getPreferenceScreen().getSharedPreferences()
.registerOnSharedPreferenceChangeListener(this);
How to get the number of preferences?
PreferenceScreen prefScreen = getPreferenceScreen();
int count = prefScreen.getPreferenceCount();