Code example for PreferenceScreen

Methods: findPreferenceremovePreference

0
        int vmailColor = Settings.System.getInt(resolver, NOTIFICATION_LIGHT_PULSE_VMAIL_COLOR, mDefaultColor);
        int vmailTimeOn = Settings.System.getInt(resolver, NOTIFICATION_LIGHT_PULSE_VMAIL_LED_ON, mDefaultLedOn);
        int vmailTimeOff = Settings.System.getInt(resolver, NOTIFICATION_LIGHT_PULSE_VMAIL_LED_OFF, mDefaultLedOff);
 
        PreferenceScreen prefSet = getPreferenceScreen();
        PreferenceGroup generalPrefs = (PreferenceGroup) prefSet.findPreference("general_section");
        if (generalPrefs != null) {
 
            // Pulse preference 
            CheckBoxPreference cPref = (CheckBoxPreference) prefSet.findPreference(PULSE_PREF);
            cPref.setChecked(mLightEnabled);
            cPref.setOnPreferenceChangeListener(this);
 
            // Default preference 
            mDefaultPref = (ApplicationLightPreference) prefSet.findPreference(DEFAULT_PREF);
            mDefaultPref.setAllValues(color, timeOn, timeOff);
            mDefaultPref.setEnabled(mLightEnabled);
            mDefaultPref.setOnPreferenceChangeListener(this);
 
            // Custom enabled preference 
            mCustomEnabledPref = (CheckBoxPreference) prefSet.findPreference(CUSTOM_PREF);
            mCustomEnabledPref.setChecked(mCustomEnabled);
            mCustomEnabledPref.setEnabled(mLightEnabled);
            mCustomEnabledPref.setOnPreferenceChangeListener(this);
        } 
 
        PreferenceGroup phonePrefs = (PreferenceGroup) prefSet.findPreference("phone_list");
        if (phonePrefs != null) {
 
            // Missed call and Voicemail preferences 
            // Should only show on devices with a voice capabilities 
            if (!mVoiceCapable) {
                prefSet.removePreference(phonePrefs);
            } else { 
                mCallPref = (ApplicationLightPreference) prefSet.findPreference(MISSED_CALL_PREF);
                mCallPref.setAllValues(callColor, callTimeOn, callTimeOff);
                mCallPref.setEnabled(mCustomEnabled);
                mCallPref.setOnPreferenceChangeListener(this);
 
                mVoicemailPref = (ApplicationLightPreference) prefSet.findPreference(VOICEMAIL_PREF);
                mVoicemailPref.setAllValues(vmailColor, vmailTimeOn, vmailTimeOff);
                mVoicemailPref.setEnabled(mCustomEnabled);
                mVoicemailPref.setOnPreferenceChangeListener(this);
            } 
        } 
 
        mApplicationPrefList = (PreferenceGroup) prefSet.findPreference("applications_list");
        mApplicationPrefList.setOrderingAsAdded(false);
    } 
 
    private void refreshCustomApplicationPrefs() { 
        Context context = getActivity();
Experience pair programming with AI  Get Codota for Java