5

I have a preference xml file that at some point of it it looks like this:

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="Hello there">
<!-- Profile ** -->
<PreferenceScreen
    android:key="profile"
    android:summary="Let app access my profile info such as name, picture and other account information."
    android:title="User Profile">
    <CheckBoxPreference
        android:defaultValue="true"
        android:key="pref_profile"
        android:summary="Let app access my profile such as name, picture and other account information."
        android:title="My Profile" />

As you can see I have 2 preferenceScreen. I want to get the preferenceScreen of the CheckBoxPreference(so the preference screen with key: profile). When i use:

PreferenceScreen prefScreen = getPreferenceScreen();

I get the one with the title: Hello there. How can i get the direct parent(first parent) screen of this checkBoxPreference? I want to get it so i can disable or enable its view.

Any ideas??Thanks!!

  • Use `findPreference(CharSequence key)` put the key like this `findPreference("profile");` – bean_droid Mar 11 '15 at 10:03
  • Ok. But the problem with this is that I have that in a loop because i want to repeat this process for other checkBoxes as well so it would be nice if somehow i could get the key of that preferenceScreen for everytime that I repeat this process(so for every other checkBox). Any idea how to do that?? –  Mar 11 '15 at 12:26

0 Answers0