Android (MultiSelect-)ListPrefernce disable entries

171 Views Asked by At

Struggeling hard to get a multiselectlistprefernce to have some entries prechecked and/or disabled.

Found some solutions for implementing a custom eg. CheckboxPreference with a custom layout files. But IMHO this will not work with ListPreferences, as they have a dynamic size.

Is it possible to extend a MultiSelectListPreference and get checkbox and label at certain position to call textview#enabled or checkbox#setchecked?

I made a mock to illustrate:

enter image description here

2

There are 2 best solutions below

0
sanjana On

you can use AlertDiaolg.multiselect and can achieve this functionality

0
Martin Zeitler On

Just extend Preference and show a custom DialogFragment with a RecyclerView and two different view-types (or drop that mock-up into there); then one can inflate either an enabled or disabled layout - or change each card-view, depending on other values. Within a PreferenceScreen it is all rather rigid and limited, but not when displaying a DialogFragment.