Selecting default values for multi select list preference

2.9k views Asked by At

I am working on an android app where I have implemented preference activity. I want to set more than one default values for Multi Select Preferences, how should I do it?

I want to do it programatically and not via layout

3

There are 3 answers

2
Parth Kapadia On BEST ANSWER

Try using :

listPreferenceData.setValues(defaultValue);

Here the defaultValue is the Set of the entry values which you wish to set as the default values.

0
prat On

Multi select ListPreference comes natively with Android from API level 11. For more information on this please check:

http://developer.android.com/reference/android/preference/MultiSelectListPreference.html

And for example ,you can check this http://blog.350nice.com/wp/archives/240

0
Abhishek T. On

MultiSelectListPreference comes natively with Android from API level 11.

setValues method is used to set default value to MultiSelectListPreference.

void setValues (Set<String> values)

Sets the value of the key. This should contain entries in getEntryValues()

For example mListPref.setValue(defaultValue);