Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using logical NOT with android:dependency from preferences

http://developer.android.com/reference/android/preference/Preference.html#attr_android:dependency

if I want my list to be dependent from other check preference named on_off I can do this

<ListPreference
    android:defaultValue="100"
    android:dependency="on_off"
    android:dialogTitle="text"
    android:entries="@array/display_values"
    android:entryValues="@array/entry_values"
    android:key="preferences_text"
    android:summary="text"
    android:title="text" />

and every time when the check preference on_off have value false this list preference will be disabled.

But what If I want everytime when on_off is true the list preference to be disabled ? I need something like logical NOT for the android:dependency

is this possible ?

like image 418
user3106633 Avatar asked Jan 21 '14 11:01

user3106633


1 Answers

In preference XML, set android:disableDependentsState attribute of the "on_off" CheckBoxPreference to true. E.g.:

<CheckBoxPreference
    android:disableDependentsState="true"
    android:key="on_off"
    android:summaryOff="Dependent is enabled"
    android:summaryOn="Dependent is disabled"
    android:title="Checkbox that disables its dependents state in reverse manner" />
like image 159
ozbek Avatar answered Nov 02 '22 23:11

ozbek