First of all, sorry for my bad english.

I found the answer in the android sdk source code, the problem is the
following:

When your "CheckBoxPreference" or an other "Preference" class call the
setDependency() method, this one will call the following method:
"PreferenceManager.findPreference()" in the background.
Exactly here is the problem, this works not untill you have called
this method "setPreferenceScreen(preferenceScreen)" in your
PreferenceActivity.

When you change the call order in your PreferenceActivity to the
following or an analog version, all works fine

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initPreferenceScreen()
    }

    private void initPreferenceScreen() {
        PreferenceScreen preferenceScreen = getPreferenceManager
().createPreferenceScreen(this);
        this.setPreferenceScreen(preferenceScreen);

        CheckBoxPreference chbPref1 = new CheckBoxPreference(this);
        chbPref1.setTitle("chbPref1");
        chbPref1.setKey("preferenceKey1");
        preferenceScreen.addPreference(chbPref1);

        CheckBoxPreference chbPref2 = new CheckBoxPreference(this);
        chbPref2.setTitle("chbPref2");
        chbPref2.setKey("preferenceKey2");
        preferenceScreen.addPreference(chbPref2);
        chbPref2.setDependency(chbPref1.getKey());
   }

This snippet is analog to my version, but this one is untested.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to