Code example for PreferenceGroup

Methods: setEnabled, setOrderingAsAdded

0
                mVoicemailPref.setOnPreferenceChangeListener(this);
            } 
        } 
 
        mApplicationPrefList = (PreferenceGroup) prefSet.findPreference("applications_list");
        mApplicationPrefList.setOrderingAsAdded(false);
    } 
 
    private void refreshCustomApplicationPrefs() { 
        Context context = getActivity();
 
        if (!parsePackageList()) { 
            return; 
        } 
 
        // Add the Application Preferences 
        if (mApplicationPrefList != null) {
            mApplicationPrefList.removeAll();
 
            for (Package pkg : mPackages.values()) {
                try { 
                    PackageInfo info = mPackageManager.getPackageInfo(pkg.name,
                            PackageManager.GET_META_DATA);
                    ApplicationLightPreference pref =
                            new ApplicationLightPreference(context, pkg.color, pkg.timeon, pkg.timeoff);
 
                    pref.setKey(pkg.name);
                    pref.setTitle(info.applicationInfo.loadLabel(mPackageManager));
                    pref.setIcon(info.applicationInfo.loadIcon(mPackageManager));
                    pref.setPersistent(false);
                    pref.setOnPreferenceChangeListener(this);
 
                    mApplicationPrefList.addPreference(pref);
                } catch (NameNotFoundException e) {
                    // Do nothing 
                } 
            } 
        } 
    } 
 
    private void setCustomEnabled() { 
        boolean enabled = mCustomEnabled && mLightEnabled;
 
        // Phone related preferences 
        if (mVoiceCapable) {
            mCallPref.setEnabled(enabled);
            mVoicemailPref.setEnabled(enabled);
        } 
 
        // Custom applications 
        if (mApplicationPrefList != null) {
            mApplicationPrefList.setEnabled(enabled);
            setHasOptionsMenu(enabled);
        } 
    } 
 
    private void addCustomApplicationPref(String packageName) {