Example usage for android.preference PreferenceCategory setEnabled

List of usage examples for android.preference PreferenceCategory setEnabled

Introduction

In this page you can find the example usage for android.preference PreferenceCategory setEnabled.

Prototype

public void setEnabled(boolean enabled) 

Source Link

Document

Sets whether this Preference is enabled.

Usage

From source file:fi.iki.murgo.irssinotifier.SettingsActivity.java

private void handleIcb() {
    CheckBoxPreference showIcbIconPreference = (CheckBoxPreference) findPreference("IcbEnabled");
    if (!IntentSniffer.isPackageAvailable(this, IrssiConnectbotLauncher.PACKAGE_IRSSICONNECTBOT)) {
        PreferenceCategory icbCategory = (PreferenceCategory) findPreference("IcbCategory");
        icbCategory.setEnabled(false);

        showIcbIconPreference.setChecked(false);
        showIcbIconPreference.setSummary("Install Irssi ConnectBot to show it in the action bar");
    } else {/*from  w ww .ja v a2 s  .  c o m*/
        showIcbIconPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                IrssiNotifierActivity.refreshIsNeeded();

                return true;
            }
        });

        Preference icbHostPref = findPreference("IcbHost");

        Preferences prefs = new Preferences(this);
        String hostName = prefs.getIcbHostName();

        String summary = "Select which Irssi ConnectBot host to open when pressing the ICB icon";
        if (hostName != null)
            summary += ". Currently selected host: " + hostName;
        icbHostPref.setSummary(summary);

        icbHostPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
            public boolean onPreferenceClick(Preference preference) {
                Intent i = new Intent("android.intent.action.PICK");
                i.setClassName(IrssiConnectbotLauncher.PACKAGE_IRSSICONNECTBOT,
                        IrssiConnectbotLauncher.PACKAGE_IRSSICONNECTBOT + ".HostListActivity");
                startActivityForResult(i, ICB_HOST_REQUEST_CODE);
                return true;
            }
        });
    }
}