Android: ListPreference hide/disable value
android, android-preferences
Solution
AFAIK, `ListPreference` does not support this. You might be able to create your own subclass of `ListPreference` where you use a custom `Adapter` and indicate which items are and are not enabled.
Problem
I'm generating a listPreference dialog based on xml (entries and entryValues). ``` <string-array name="listArray"> <item>Title (A-Z)</item> <item>Title (Z-A)</item> <item>Visits (default)</item> <item>Date</item> <item>Manual</item> </string-array> <string-array name="listValues"> <item>titleASC</item> <item>titleDESC</item> <item>visitsSort</item> <item>createSort</item> <item>manualSort</item> </string-array> ``` I want to hide/disable some of the entries (for example: Manual) based on some other parameters. I understand it should be inside this scope: ``` Preference sorted = (Preference) findPreference(OPT_SORT); sorted.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { if (params) { What should i put here to hide/disable some of the entries? } return true; } }); ``` Thank you! EDIT: Best solution I found is to load a different set of Entries and EntryValues. On Preference class (onCreate): ``` ListPreference sortBy = (ListPreference) findPreference(OPT_SORT); if (isTabletDevice()) { sortBy.setEntries(getResources().getStringArray(R.array.HClistArray)); sortBy.setEntryValues(getResources().getStringArray(R.array.HClistValues)); } ``` Hope this helps anyone! :)