Preferences Flashcards

1
Q

a Java class implements ?? for understanding the changes in the shared preferences

A

OnSharedPreferenceChangeListener

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How should we add an edit text preferences:

A
//in setSummary
 if (preference instanceof EditTextPreference) {
            // For EditTextPreferences, set the summary to the value's simple string representation.
            preference.setSummary(value);
        }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

We wanna make a list preference! What should we add in the XML resource file?

A

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–>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What kinda theme should we add for adding preference?

A

preferenceTheme added to styles.XML like this:

@style/PreferenceThemeOverlay

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Can we find a preference by Key?

A

Yes we do!

Preference preference = findPreference(key);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you register a SharedPreferenceChangedListener? What do you Register it to?

A

getPreferenceScreen().getSharedPreferences()

.registerOnSharedPreferenceChangeListener(this);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to get the number of preferences?

A

PreferenceScreen prefScreen = getPreferenceScreen();

int count = prefScreen.getPreferenceCount();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly