当前位置: 首页>>代码示例>>Java>>正文


Java CheckBoxPreference类代码示例

本文整理汇总了Java中android.preference.CheckBoxPreference的典型用法代码示例。如果您正苦于以下问题:Java CheckBoxPreference类的具体用法?Java CheckBoxPreference怎么用?Java CheckBoxPreference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CheckBoxPreference类属于android.preference包,在下文中一共展示了CheckBoxPreference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.preference.CheckBoxPreference; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.prefs = getSharedPreferences(Common.PREFS, Context.MODE_WORLD_READABLE);
    addPreferencesFromResource(R.xml.preference);

    mSwith = (SwitchPreference) findPreference("enable_toast");
    mStyle = (ListPreference) findPreference("style_key");
    mAnimation = (ListPreference) findPreference("animation_key");
    mEnable_icon = (CheckBoxPreference) findPreference("enable_icon");
    mGithub = findPreference("viewsource");


    mSwith.setOnPreferenceChangeListener(this);
    mStyle.setOnPreferenceChangeListener(this);
    mAnimation.setOnPreferenceChangeListener(this);
    mEnable_icon.setOnPreferenceChangeListener(this);
    mGithub.setOnPreferenceClickListener(this);
}
 
开发者ID:heshshark,项目名称:ToastUI,代码行数:21,代码来源:SettingActivity.java

示例2: setupGaplessControlSettingsV14

import android.preference.CheckBoxPreference; //导入依赖的package包/类
private void setupGaplessControlSettingsV14() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        PreferenceCategory playbackControlSettings =
                (PreferenceCategory) findPreference(Constants.PREFERENCES_KEY_PLAYBACK_CONTROL_SETTINGS);
        CheckBoxPreference gaplessPlaybackEnabled =
                (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_GAPLESS_PLAYBACK);

        if (gaplessPlaybackEnabled != null) {
            gaplessPlaybackEnabled.setChecked(false);
            gaplessPlaybackEnabled.setEnabled(false);

            if (playbackControlSettings != null) {
                playbackControlSettings.removePreference(gaplessPlaybackEnabled);
            }
        }
    }
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:18,代码来源:SettingsFragment.java

示例3: onViewCreated

import android.preference.CheckBoxPreference; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    serverNamePref = (EditTextPreference) findPreference(getString(R.string.settings_server_name));
    serverUrlPref = (EditTextPreference) findPreference(getString(R.string.settings_server_address));
    serverUsernamePref = (EditTextPreference) findPreference(getString(R.string.settings_server_username));
    serverPasswordPref = (EditTextPreference) findPreference(getString(R.string.settings_server_password));
    equalizerPref = (CheckBoxPreference) findPreference(getString(R.string.equalizer_enabled));
    jukeboxPref = (CheckBoxPreference) findPreference(getString(R.string.jukebox_is_default));
    removeServerPref = findPreference(getString(R.string.settings_server_remove_server));
    testConnectionPref = findPreference(getString(R.string.settings_test_connection_title));
    allowSelfSignedCertificatePref = (CheckBoxPreference) findPreference(
            getString(R.string.settings_allow_self_signed_certificate));

    setupPreferencesValues();
    setupPreferencesListeners();
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:19,代码来源:ServerSettingsFragment.java

示例4: disableLastCheckedPref

import android.preference.CheckBoxPreference; //导入依赖的package包/类
private void disableLastCheckedPref() {
  Collection<CheckBoxPreference> checked = new ArrayList<CheckBoxPreference>(3);
  if (decode1D.isChecked()) {
    checked.add(decode1D);
  }
  if (decodeQR.isChecked()) {
    checked.add(decodeQR);
  }
  if (decodeDataMatrix.isChecked()) {
    checked.add(decodeDataMatrix);
  }
  boolean disable = checked.size() < 2;
  CheckBoxPreference[] checkBoxPreferences = {decode1D, decodeQR, decodeDataMatrix};
  for (CheckBoxPreference pref : checkBoxPreferences) {
    pref.setEnabled(!(disable && checked.contains(pref)));
  }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:18,代码来源:PreferencesFragment.java

示例5: onPause

import android.preference.CheckBoxPreference; //导入依赖的package包/类
@Override
protected void onPause() {
    super.onPause();
    // Save the selected languages
    String checkedLanguages = "";
    PreferenceGroup parent = getPreferenceScreen();
    int count = parent.getPreferenceCount();
    for (int i = 0; i < count; i++) {
        CheckBoxPreference pref = (CheckBoxPreference) parent.getPreference(i);
        if (pref.isChecked()) {
            Locale locale = mAvailableLanguages.get(i).locale;
            checkedLanguages += get5Code(locale) + ",";
        }
    }
    if (checkedLanguages.length() < 1) checkedLanguages = null; // Save null
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    Editor editor = sp.edit();
    editor.putString(KP2AKeyboard.PREF_SELECTED_LANGUAGES, checkedLanguages);
    SharedPreferencesCompat.apply(editor);
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:21,代码来源:InputLanguageSelection.java

示例6: onCreate

import android.preference.CheckBoxPreference; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
    useTorCheckPref = (CheckBoxPreference) findPreference(Preferences.PREF_USE_TOR);
    enableProxyCheckPref = (CheckBoxPreference) findPreference(Preferences.PREF_ENABLE_PROXY);
    updateAutoDownloadPref = findPreference(Preferences.PREF_AUTO_DOWNLOAD_INSTALL_UPDATES);
    updatePrivilegedExtensionPref = findPreference(Preferences.PREF_UNINSTALL_PRIVILEGED_APP);

    AppCompatListPreference languagePref = (AppCompatListPreference) findPreference(Preferences.PREF_LANGUAGE);
    if (Build.VERSION.SDK_INT >= 24) {
        PreferenceCategory category = (PreferenceCategory) findPreference("pref_category_display");
        category.removePreference(languagePref);
    } else {
        Languages languages = Languages.get(getActivity());
        languagePref.setDefaultValue(Languages.USE_SYSTEM_DEFAULT);
        languagePref.setEntries(languages.getAllNames());
        languagePref.setEntryValues(languages.getSupportedLocales());
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:21,代码来源:PreferencesFragment.java

示例7: onCreate

import android.preference.CheckBoxPreference; //导入依赖的package包/类
@Override
public void onCreate(Bundle paramBundle) {
  super.onCreate(paramBundle);
  addPreferencesFromResource(R.xml.preferences_app_protection);

  masterSecret      = getArguments().getParcelable("master_secret");
  disablePassphrase = (CheckBoxPreference) this.findPreference("pref_enable_passphrase_temporary");

  this.findPreference(TextSecurePreferences.CHANGE_PASSPHRASE_PREF)
      .setOnPreferenceClickListener(new ChangePassphraseClickListener());
  this.findPreference(TextSecurePreferences.PASSPHRASE_TIMEOUT_INTERVAL_PREF)
      .setOnPreferenceClickListener(new PassphraseIntervalClickListener());
  this.findPreference(PREFERENCE_CATEGORY_BLOCKED)
      .setOnPreferenceClickListener(new BlockedContactsClickListener());
  disablePassphrase
      .setOnPreferenceChangeListener(new DisablePassphraseClickListener());
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:18,代码来源:AppProtectionPreferenceFragment.java

示例8: updatePreferenceSummary

import android.preference.CheckBoxPreference; //导入依赖的package包/类
public void updatePreferenceSummary() {
    CheckBoxPreference bloodPreference = (CheckBoxPreference) findPreference("checkBoxBlood");
    bloodPreference.setChecked(sharedPreferences.getBoolean("checkBoxBlood", true));

    // Set nagging preference summary
    int nagMinutes = sharedPreferences.getInt("nagMinutes", getResources().getInteger(R.integer.default_nag_minutes));
    int nagSeconds = sharedPreferences.getInt("nagSeconds", getResources().getInteger(R.integer.default_nag_seconds));
    Preference nagPreference = findPreference("nagInterval");
    String nagMinutesText = String.format(getActivity().getResources().getQuantityString(R.plurals.time_minute, nagMinutes), nagMinutes);
    String nagSecondsText = String.format(getActivity().getResources().getQuantityString(R.plurals.time_second, nagSeconds), nagSeconds);
    nagPreference.setSummary(String.format("%s %s", nagMinutesText, nagSecondsText));

    SharedPreferences.Editor editor = s1.edit();
    editor.putBoolean("sos", sharedPreferences.getBoolean("checkBoxSOS", s1.getBoolean("sos", true)));
    editor.apply();

    ((MyApplication) getActivity().getApplication()).createSOSNotification();
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:19,代码来源:PreferenceFragment.java

示例9: replaceAllCheckBoxPreferencesBySwitchPreferences

import android.preference.CheckBoxPreference; //导入依赖的package包/类
private static void replaceAllCheckBoxPreferencesBySwitchPreferences(
        final PreferenceGroup group) {
    final ArrayList<Preference> preferences = new ArrayList<>();
    final int count = group.getPreferenceCount();
    for (int index = 0; index < count; index++) {
        preferences.add(group.getPreference(index));
    }
    group.removeAll();
    for (int index = 0; index < count; index++) {
        final Preference preference = preferences.get(index);
        if (preference instanceof CheckBoxPreference) {
            addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference)preference, group);
        } else {
            group.addPreference(preference);
            if (preference instanceof PreferenceGroup) {
                replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup)preference);
            }
        }
    }
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:21,代码来源:TwoStatePreferenceHelper.java

示例10: setKeys

import android.preference.CheckBoxPreference; //导入依赖的package包/类
private void setKeys(PreferenceScreen screen)
{
	for(int i = 0; i < screen.getPreferenceCount(); i++)
	{
		Preference preference = screen.getPreference(i);
		String key = server + ";" + preference.getKey();
		preference.setKey(key);
		if(preference instanceof EditIntPreference)
			((EditIntPreference)preference).setInt(preference.getSharedPreferences().getInt(key, -1));
		else if(preference instanceof EditTextPreference)
			((EditTextPreference)preference).setText(preference.getSharedPreferences().getString(key, null));
		else if(preference instanceof ListPreference)
			((ListPreference)preference).setValue(preference.getSharedPreferences().getString(key, null));
		else if(preference instanceof CheckBoxPreference)
			((CheckBoxPreference)preference).setChecked(preference.getSharedPreferences().getBoolean(key, false));
		if(preference instanceof PreferenceScreen)
			setKeys((PreferenceScreen)preference);
	}
}
 
开发者ID:mniip,项目名称:bananapeel,代码行数:20,代码来源:ServerPreferencesScreen.java

示例11: bindPreferenceSummaryToValue

import android.preference.CheckBoxPreference; //导入依赖的package包/类
/**
 * Binds a preference's summary to its value. More specifically, when the
 * preference's value is changed, its summary (line of text below the
 * preference title) is updated to reflect the value. The summary is also
 * immediately updated upon calling this method. The exact display format is
 * dependent on the type of preference.
 *
 * @see #sBindPreferenceSummaryToValueListener
 */
private static void bindPreferenceSummaryToValue(Preference preference) {
    // Set the listener to watch for value changes.
    preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);

    // Trigger the listener immediately with the preference' current value.
    if (preference instanceof ListPreference
            || preference instanceof EditTextPreference) {
        sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
                PreferenceManager
                        .getDefaultSharedPreferences(preference.getContext())
                        .getString(preference.getKey(), ""));
    } else if (preference instanceof SwitchPreference
            || preference instanceof CheckBoxPreference) {
        sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
                PreferenceManager
                        .getDefaultSharedPreferences(preference.getContext())
                        .getBoolean(preference.getKey(),true));
    }
}
 
开发者ID:an-garcia,项目名称:MovieGuide,代码行数:29,代码来源:SettingsActivity.java

示例12: addCheckBox

import android.preference.CheckBoxPreference; //导入依赖的package包/类
private CheckBoxPreference addCheckBox(String title, PreferenceCategory category, String key, Drawable icon, String onText, String offText, boolean defaultValue, Context context) {
    CheckBoxPreference c = new CheckBoxPreference(context);
    c.setTitle(title);
    c.setKey(key);
    if (null != icon) c.setIcon(icon);
    if (offText.equals(null) || onText.equals(null)) {
        if (offText.equals(null)) {
            c.setSummary(onText);
        } else if (onText.equals(null)) {
            c.setSummary(offText);
        }
    } else {
        c.setSummaryOn(onText);
        c.setSummaryOff(offText);
    }
    c.setDefaultValue(defaultValue);
    c.setChecked(KRFAM.sharedPreferences.getBoolean(key, defaultValue));
    category.addPreference(c);
    return c;
}
 
开发者ID:iebb,项目名称:Kasumi,代码行数:21,代码来源:AppPreferences.java

示例13: setDynamicMsgBgColor

import android.preference.CheckBoxPreference; //导入依赖的package包/类
private void setDynamicMsgBgColor(final CheckBoxPreference checkBoxPreference, final ColorPreference hue, final ColorPreference hueDark)
{
    hue.setEnabled(!checkBoxPreference.isChecked());
    hueDark.setEnabled(!checkBoxPreference.isChecked());
    final CheckBoxPreference darkThemePref = (CheckBoxPreference) findPreference("dark_theme");

    checkBoxPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
    {
        @Override
        public boolean onPreferenceChange(Preference preference, Object o)
        {
            if (darkThemePref.isChecked())
            {
                hueDark.setEnabled(!(boolean) o);
                hue.setEnabled(false);
            }
            else
            {
                hue.setEnabled(!(boolean) o);
                hueDark.setEnabled(false);
            }

            return true;
        }
    });
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:27,代码来源:PreferencesActivity.java

示例14: setSameFabColor

import android.preference.CheckBoxPreference; //导入依赖的package包/类
private void setSameFabColor(final CheckBoxPreference sameFabColor, final ColorPreference hue)
{
    sameFabColor.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
    {
        @Override
        public boolean onPreferenceChange(Preference preference, Object o)
        {
            if ((boolean) o)
            {
                hue.setEnabled(false);
            }
            else
            {
                hue.setEnabled(true);
            }
            return true;
        }
    });
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:20,代码来源:PreferencesActivity.java

示例15: onCreate

import android.preference.CheckBoxPreference; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.custom_prefs);

    // This sample app uses shared preferences to maintain app restriction settings.  Your app
    // can use other methods to maintain the settings.
    mBooleanPref = (CheckBoxPreference) findPreference(KEY_BOOLEAN_PREF);
    mChoicePref = (ListPreference) findPreference(KEY_CHOICE_PREF);
    mMultiPref = (MultiSelectListPreference) findPreference(KEY_MULTI_PREF);

    mBooleanPref.setOnPreferenceChangeListener(this);
    mChoicePref.setOnPreferenceChangeListener(this);
    mMultiPref.setOnPreferenceChangeListener(this);

    setRetainInstance(true);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:18,代码来源:CustomRestrictionsFragment.java


注:本文中的android.preference.CheckBoxPreference类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。