I have this CheckBoxPreference
CheckBoxPreference sendToEmailPref = new CheckBoxPreference(this);
sendToEmailPref.setTitle("Send To Email");
sendToEmailPref.setDependency("emailList");
I want to set its dependency on a key "emailList" emailList is a custom build preference which stores the email addressees as a String.
However, I am getting this error
Caused by: java.lang.IllegalStateException: Dependency not found.....
you should call setDependency after you have finished calling addPreference It works for me well!
Get your .setDependency() to just after setPreferenceScreen() in your onCreate. It should work.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setPreferenceScreen(createPreferenceHierarchy());
getPreferenceScreen().findPreference("_key_of_depend_to_").setDependency("emailList");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With