Reputation: 9234
Why its not work in Code ? in XML its ok, but not in Code.
String [] testValues = {"a" , "b", "c"};
ListPreference test = (ListPreference)findPreference(KEY);
test.setEntries(testValues);
test.setEntryValues(testValues);
test.setDefaultValue(testValue[0]);
Upvotes: 2
Views: 4616
Reputation: 949
Instead of using setDefaultValue
on ListPreference
, you may use setValue
to change the value. The complete code would be:
String [] testValues = {"a" , "b", "c"};
ListPreference test = (ListPreference)findPreference(KEY);
test.setEntries(testValues);
test.setEntryValues(testValues);
test.setValue(testValue[0]);
Upvotes: -1