I have a checkbox and ListPreference, I would like to disable / enable ListPreference using checkbox. I read a lot and I only found it possible to use java (and not xml). Is it correct? Now, after reading the value of "checkboxPref" (boolean true / false), I do not understand.
SharedPreferences prefs3 = PreferenceManager.getDefaultSharedPreferences(this); listener = new SharedPreferences.OnSharedPreferenceChangeListener() { public void onSharedPreferenceChanged(SharedPreferences prefs, String listpref) { CheckboxPreference = prefs.getBoolean("checkboxPref", true); } }; prefs3.registerOnSharedPreferenceChangeListener(listener);
preferences.xml:
<CheckBoxPreference android:title="Notifify" android:defaultValue="true" android:key="checkboxPref" /> <ListPreference android:entries="@array/numberOptions" android:entryValues="@array/numberValues" android:key="number" android:title="Number" />
Pol hallen
source share