ListPreference dependency

Viewed 12319

I have a ListPreference which look something like this:

<ListPreference
android:title="Choose item"
android:summary="..."
android:key="itemList"
android:defaultValue="item1"
android:entries="@array/items"
android:entryValues="@array/itemValues" />

Then, I have another preference which should only be enabled if "item3" is selected in the ListPreference.

Can I somehow accomplish this with android:dependency? Something like android:dependency="itemList:item3"

Thanks!

4 Answers

in the xml add the line

app:isPreferenceVisible="false"

Then add an onClickListener to item3 in the java that sets the item to true when selected

Related