本文整理汇总了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);
}
}
}
}
示例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();
}
示例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;
}
示例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());
}
示例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;
});
}
示例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);
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
}
示例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());
}
示例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();
}
示例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()]);
}
示例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 + ") ");
}