How to set dependency by the ListPreference values?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As already pointed out by Snicolas, the depency xml feature only checks for a boolean state (= if the referenced key is true or a value is set in it). If enabled, you can use this preference, if it is not, you can’t.
To archieve a depency when a certain ListPreference entry is selected, you have to write some logic in code. I’d solve this by using a
OnSharedPreferenceChangedListener. When the preference/key thats associated with your ListPreference changes, test to which value it has changed. If it now has one that enables or disables your preference, usePreference.setEnabled()to change it.