當前位置: 首頁>>代碼示例>>Java>>正文


Java CheckBoxPreference.setChecked方法代碼示例

本文整理匯總了Java中android.preference.CheckBoxPreference.setChecked方法的典型用法代碼示例。如果您正苦於以下問題:Java CheckBoxPreference.setChecked方法的具體用法?Java CheckBoxPreference.setChecked怎麽用?Java CheckBoxPreference.setChecked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.preference.CheckBoxPreference的用法示例。


在下文中一共展示了CheckBoxPreference.setChecked方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: onCreate

import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.settings);
    getPreferenceManager().setSharedPreferencesName(SettingUtils.SETTING_SP_NAME);

    // Preference Fragment隻是一次性的動作,並不會持久化你的選擇,需要自己處理
    mNoOfflineSell = (CheckBoxPreference) findPreference(SettingUtils.NO_OFFLINE_SELL);
    mNoOfflineSell.setChecked(SettingUtils.noOfflineSell());

    // 注意兩個Util的不同,第一個SPUtils是為了處理第二個SettingUtils首次為選中
    final String SP_TEXT = "SP_FIRST_AUTO_UPDATE";
    if (!SPUtils.getBoolean(SP_TEXT)) {
        SettingUtils.save(SettingUtils.AUTO_CHECK_UPDATE, true);
        SPUtils.save(SP_TEXT, true);
    }
    mAutoCheckUpdate = (CheckBoxPreference) findPreference(SettingUtils.AUTO_CHECK_UPDATE);
    mAutoCheckUpdate.setChecked(SettingUtils.autoCheckUpdate());

}
 
開發者ID:leelit,項目名稱:STUer-client,代碼行數:21,代碼來源:SettingActivity.java

示例5: onCreate

import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.dev_options);

    CheckBoxPreference leakPref = (CheckBoxPreference) findPreference(KEY_LEAK_CANARY);
    if (isDebugVersion()) {
        leakPref.setChecked(isLeakCanaryEnabled(getActivity()));
        leakPref.setOnPreferenceChangeListener((preference, newValue) -> {
            final SharedPreferences prefs = getPrefs(preference.getContext());
            prefs.edit().putBoolean(KEY_LEAK_CANARY, (Boolean) newValue).apply();
            return true;
        });
    } else {
        getPreferenceScreen().removePreference(leakPref);
    }

    Preference prefTrackerPref = findPreference(KEY_PERF_DEBUG_SCREEN);
    prefTrackerPref.setOnPreferenceClickListener(preference -> {
        WhistlePunkApplication.getPerfTrackerProvider(getContext())
                .startPerfTrackerEventDebugActivity(getContext());
        return true;
    });
}
 
開發者ID:google,項目名稱:science-journal,代碼行數:26,代碼來源:DevOptionsFragment.java

示例6: onCreate

import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());

    PreferenceCategory category = new PreferenceCategory(getActivity());
    category.setTitle("Libraries");

    screen.addPreference(category);

    CheckBoxPreference checkBoxPref = new CheckBoxPreference(getActivity());
    checkBoxPref.setTitle("title");
    checkBoxPref.setSummary("summary");
    checkBoxPref.setChecked(true);

    category.addPreference(checkBoxPref);
    setPreferenceScreen(screen);
}
 
開發者ID:mrspaceman,項目名稱:ebookmgr,代碼行數:19,代碼來源:SettingsActivity.java

示例7: initializeCalendarReminderPreference

import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void initializeCalendarReminderPreference() {
    CheckBoxPreference calendarReminderPreference = (CheckBoxPreference) findPreference(getString(R.string.p_calendar_reminders));
    calendarReminderPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (newValue == null) {
                return false;
            }
            if (!(Boolean) newValue) {
                return true;
            }
            if (permissionRequestor.requestCalendarPermissions()) {
                backgroundScheduler.scheduleCalendarNotifications();
                return true;
            }
            return false;
        }
    });
    calendarReminderPreference.setChecked(calendarReminderPreference.isChecked() && permissionChecker.canAccessCalendars());
}
 
開發者ID:andyCano,項目名稱:TaskApp,代碼行數:21,代碼來源:MiscellaneousPreferences.java

示例8: uncheckAndHidePreference

import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void uncheckAndHidePreference(int preferenceKey) {
	Preference preference = findPreference(getString(preferenceKey));
	if (!(preference instanceof CheckBoxPreference))
		return;

	CheckBoxPreference checkBoxPreference = (CheckBoxPreference) preference;
	checkBoxPreference.setChecked(false);
	hidePreference(checkBoxPreference);
}
 
開發者ID:treasure-lau,項目名稱:Linphone4Android,代碼行數:10,代碼來源:SettingsFragment.java

示例9: initCallSettings

import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void initCallSettings() {
	CheckBoxPreference deviceRingtone = (CheckBoxPreference) findPreference(getString(R.string.pref_device_ringtone_key));
	CheckBoxPreference autoAnswer = (CheckBoxPreference) findPreference(getString(R.string.pref_auto_answer_key));
	CheckBoxPreference rfc2833 = (CheckBoxPreference) findPreference(getString(R.string.pref_rfc2833_dtmf_key));
	CheckBoxPreference sipInfo = (CheckBoxPreference) findPreference(getString(R.string.pref_sipinfo_dtmf_key));

	deviceRingtone.setChecked(mPrefs.isDeviceRingtoneEnabled());
	autoAnswer.setChecked(mPrefs.isAutoAnswerEnabled());

	rfc2833.setChecked(false);
	sipInfo.setChecked(false);

	setPreferenceDefaultValueAndSummary(R.string.pref_voice_mail_key, mPrefs.getVoiceMailUri());
}
 
開發者ID:treasure-lau,項目名稱:Linphone4Android,代碼行數:15,代碼來源:SettingsFragment.java

示例10: initNetworkSettings

import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void initNetworkSettings() {
	((CheckBoxPreference) findPreference(getString(R.string.pref_wifi_only_key))).setChecked(mPrefs.isWifiOnlyEnabled());

	// Disable UPnP if ICE si enabled, or disable ICE if UPnP is enabled
	CheckBoxPreference ice = (CheckBoxPreference) findPreference(getString(R.string.pref_ice_enable_key));
	CheckBoxPreference turn = (CheckBoxPreference) findPreference(getString(R.string.pref_turn_enable_key));
	ice.setChecked(mPrefs.isIceEnabled());
	turn.setEnabled(mPrefs.getStunServer() != null);
	turn.setChecked(mPrefs.isTurnEnabled());

	EditTextPreference turnUsername = (EditTextPreference) findPreference(getString(R.string.pref_turn_username_key));
	EditTextPreference turnPassword = (EditTextPreference) findPreference(getString(R.string.pref_turn_passwd_key));
	turnUsername.setEnabled(mPrefs.isTurnEnabled());
	turnUsername.setSummary(mPrefs.getTurnUsername());
	turnUsername.setText(mPrefs.getTurnUsername());
	turnPassword.setEnabled(mPrefs.isTurnEnabled());

	CheckBoxPreference randomPort = (CheckBoxPreference) findPreference(getString(R.string.pref_transport_use_random_ports_key));
	randomPort.setChecked(mPrefs.isUsingRandomPort());

	// Disable sip port choice if port is random
	EditTextPreference sipPort = (EditTextPreference) findPreference(getString(R.string.pref_sip_port_key));
	sipPort.setEnabled(!randomPort.isChecked());
	sipPort.setSummary(mPrefs.getSipPort());
	sipPort.setText(mPrefs.getSipPort());

	EditTextPreference stun = (EditTextPreference) findPreference(getString(R.string.pref_stun_server_key));
	stun.setSummary(mPrefs.getStunServer());
	stun.setText(mPrefs.getStunServer());

	((CheckBoxPreference) findPreference(getString(R.string.pref_push_notification_key))).setChecked(mPrefs.isPushNotificationEnabled());
	((CheckBoxPreference) findPreference(getString(R.string.pref_ipv6_key))).setChecked(mPrefs.isUsingIpv6());
}
 
開發者ID:treasure-lau,項目名稱:Linphone4Android,代碼行數:34,代碼來源:SettingsFragment.java

示例11: onCreate

import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle icicle) {
    // Get the settings preferences
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);

    Design.updateTheme(this, sp);

	super.onCreate(icicle);
    addPreferencesFromResource(R.xml.language_prefs);
    mSelectedLanguages = sp.getString(KP2AKeyboard.PREF_SELECTED_LANGUAGES, "");
    String[] languageList = mSelectedLanguages.split(",");
    
    //first try to get the unique locales in a strict mode (filtering most redundant layouts like English (Jamaica) etc.)
    mAvailableLanguages = getUniqueLocales(true);
    //sometimes the strict check returns only EN_US, EN_GB and ES_US. Accept more in these cases:
    if (mAvailableLanguages.size() < 5)
    {
    	mAvailableLanguages = getUniqueLocales(false);
    }
    PreferenceGroup parent = getPreferenceScreen();
    for (int i = 0; i < mAvailableLanguages.size(); i++) {
        CheckBoxPreference pref = new CheckBoxPreference(this);
        Locale locale = mAvailableLanguages.get(i).locale;
        pref.setTitle(LanguageSwitcher.toTitleCase(locale.getDisplayName(locale), locale));
        boolean checked = isLocaleIn(locale, languageList);
        pref.setChecked(checked);
        if (hasDictionary(locale, this)) {
            pref.setSummary(R.string.has_dictionary);
        }
        parent.addPreference(pref);
    }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:33,代碼來源:InputLanguageSelection.java

示例12: initializePushMessagingToggle

import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void initializePushMessagingToggle() {
  CheckBoxPreference preference = (CheckBoxPreference)this.findPreference(PUSH_MESSAGING_PREF);

  if (TextSecurePreferences.isPushRegistered(getActivity())) {
    preference.setChecked(true);
    preference.setSummary(TextSecurePreferences.getLocalNumber(getActivity()));
  } else {
    preference.setChecked(false);
    preference.setSummary(R.string.preferences__free_private_messages_and_calls);
  }

  preference.setOnPreferenceChangeListener(new PushMessagingClickListener());
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:14,代碼來源:AdvancedPreferenceFragment.java

示例13: onCreate

import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.prefs);

    sharedPreferences = getPreferenceScreen().getSharedPreferences();
    s1 = getActivity().getSharedPreferences("Profile", 0);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putBoolean("checkBoxSOS", s1.getBoolean("sos", true));
    editor.apply();
    CheckBoxPreference sosPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("checkBoxSOS");
    sosPreference.setChecked(sharedPreferences.getBoolean("checkBoxSOS", true));

    updatePreferenceSummary();
}
 
開發者ID:adithya321,項目名稱:SOS-The-Healthcare-Companion,代碼行數:16,代碼來源:PreferenceFragment.java

示例14: initPrefs

import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void initPrefs() {
    // mPreferences storage
    mThemeOptions = this.getResources().getStringArray(R.array.themes);
    mCurrentTheme = mPreferenceManager.getUseTheme();

    mTheme = findPreference(SETTINGS_THEME);
    Preference textSize = findPreference(SETTINGS_TEXTSIZE);
    CheckBoxPreference cbStatus = (CheckBoxPreference) findPreference(SETTINGS_HIDESTATUSBAR);
    CheckBoxPreference cbFullScreen = (CheckBoxPreference) findPreference(SETTINGS_FULLSCREEN);
    CheckBoxPreference cbViewPort = (CheckBoxPreference) findPreference(SETTINGS_VIEWPORT);
    CheckBoxPreference cbOverview = (CheckBoxPreference) findPreference(SETTINGS_OVERVIEWMODE);
    CheckBoxPreference cbReflow = (CheckBoxPreference) findPreference(SETTINGS_REFLOW);
    CheckBoxPreference cbBlackStatus = (CheckBoxPreference) findPreference(SETTINGS_BLACK_STATUS);
    CheckBoxPreference cbDrawerTabs = (CheckBoxPreference) findPreference(SETTINGS_DRAWERTABS);
    CheckBoxPreference cbSwapTabs = (CheckBoxPreference) findPreference(SETTINGS_SWAPTABS);

    mTheme.setOnPreferenceClickListener(this);
    textSize.setOnPreferenceClickListener(this);
    cbStatus.setOnPreferenceChangeListener(this);
    cbFullScreen.setOnPreferenceChangeListener(this);
    cbViewPort.setOnPreferenceChangeListener(this);
    cbOverview.setOnPreferenceChangeListener(this);
    cbReflow.setOnPreferenceChangeListener(this);
    cbBlackStatus.setOnPreferenceChangeListener(this);
    cbDrawerTabs.setOnPreferenceChangeListener(this);
    cbSwapTabs.setOnPreferenceChangeListener(this);

    cbStatus.setChecked(mPreferenceManager.getHideStatusBarEnabled());
    cbFullScreen.setChecked(mPreferenceManager.getFullScreenEnabled());
    cbViewPort.setChecked(mPreferenceManager.getUseWideViewportEnabled());
    cbOverview.setChecked(mPreferenceManager.getOverviewModeEnabled());
    cbReflow.setChecked(mPreferenceManager.getTextReflowEnabled());
    cbBlackStatus.setChecked(mPreferenceManager.getUseBlackStatusBar());
    cbDrawerTabs.setChecked(mPreferenceManager.getShowTabsInDrawer(true));
    cbSwapTabs.setChecked(mPreferenceManager.getBookmarksAndTabsSwapped());

    mTheme.setSummary(mThemeOptions[mPreferenceManager.getUseTheme()]);
}
 
開發者ID:XndroidDev,項目名稱:Xndroid,代碼行數:39,代碼來源:DisplaySettingsFragment.java

示例15: onCreate

import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.settings);
    sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
    locationInfo = ConfigPreferences.getLocationConfig(getActivity());
    //disable and enable praying notification related setting
    if (ConfigPreferences.getPrayingNotification(getActivity()) == false) {
        getPreferenceScreen().findPreference("silent").setEnabled(false);
        getPreferenceScreen().findPreference("vibration").setEnabled(false);
        getPreferenceScreen().findPreference("led").setEnabled(false);
    }

    //disable or enable silent related settings
    if(ConfigPreferences.getSilentMood(getActivity()) == false){
        getPreferenceScreen().findPreference("vibration").setEnabled(false);
    }

    if (locationInfo != null) {
        Log.i("DATA_SETTING" ,"locationInfo.dls : "+(locationInfo.dls > 0));
        CheckBoxPreference checked = (CheckBoxPreference) getPreferenceScreen().findPreference("day_light");
        checked.setChecked(locationInfo.dls > 0);
        ListPreference wayPref = (ListPreference) getPreferenceScreen().findPreference("calculations");
        Log.i("DATA_SETTING" ,"locationInfo.way : "+locationInfo.way);
        wayPref.setValueIndex(locationInfo.way);
        ListPreference mazhapPref = (ListPreference) getPreferenceScreen().findPreference("mazhab");
        mazhapPref.setValueIndex(locationInfo.mazhab);
        Log.i("DATA_SETTING" ,"locationInfo.mazhab : "+locationInfo.mazhab);
    }

    listPreference = (ListPreference) findPreference("language");
    String lang = ConfigPreferences.getApplicationLanguage(getActivity()).equalsIgnoreCase("en") ? "English" : "العربية";
    listPreference.setSummary(getString(R.string.language_summary)
            + "  (" + lang + ") ");

}
 
開發者ID:fekracomputers,項目名稱:MuslimMateAndroid,代碼行數:37,代碼來源:SettingsActivity.java


注:本文中的android.preference.CheckBoxPreference.setChecked方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。