本文整理汇总了Java中android.support.v7.preference.CheckBoxPreference.setChecked方法的典型用法代码示例。如果您正苦于以下问题:Java CheckBoxPreference.setChecked方法的具体用法?Java CheckBoxPreference.setChecked怎么用?Java CheckBoxPreference.setChecked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.preference.CheckBoxPreference
的用法示例。
在下文中一共展示了CheckBoxPreference.setChecked方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onViewCreated
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
app = (App) getContext().getApplicationContext();
view.setBackgroundColor(Color.parseColor("#FFFFFF"));
SwitchPreferenceCompat preference = (SwitchPreferenceCompat)findPreference("enableNotifications");
preference.setOnPreferenceChangeListener(onSetAlarm);
ListPreference delay = (ListPreference)findPreference("delayNotifications");
delay.setOnPreferenceChangeListener(onDelayChange);
CheckBoxPreference display = (CheckBoxPreference)findPreference("displaySilNotification");
display.setOnPreferenceChangeListener(onDisplayChange);
if (app.getPublicPreferenceB(Common.GLOBAL_SETTING_ISNOTIFON)) {
preference.setChecked(true);
delay.setEnabled(true);
delay.setValueIndex(getIdByTime(app.account.getNotificationTime()));
display.setEnabled(true);
display.setChecked(app.getPublicPreferenceB(Common.GLOBAL_SETTING_NOTIFICATIONDISPLAY));
} else {
preference.setChecked(false);
delay.setEnabled(false);
display.setEnabled(false);
display.setChecked(false);
}
}
示例2: onPreferenceChange
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
NotificationManager manager = new NotificationManager(getContext());
ListPreference delay = (ListPreference)findPreference("delayNotifications");
CheckBoxPreference display = (CheckBoxPreference)findPreference("displaySilNotification");
app.savePublicPreference(Common.GLOBAL_SETTING_ISNOTIFON, (boolean)newValue);
if ((boolean)newValue) {
delay.setEnabled(true);
display.setEnabled(true);
display.setChecked(app.getPublicPreferenceB(Common.GLOBAL_SETTING_NOTIFICATIONDISPLAY));
manager.setRecurrentService();
} else {
delay.setEnabled(false);
display.setEnabled(false);
display.setChecked(false);
manager.deactivateRecurrentService();
}
return true;
}
示例3: updatePrefDefaultValue
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
private static void updatePrefDefaultValue(Preference pref) {
String realPrefKey = pref.getKey();
pref.setPersistent(false);
if (pref instanceof CheckBoxPreference) {
pref.setKey("tmpKeyBool");
CheckBoxPreference checkBoxPref = (CheckBoxPreference) pref;
checkBoxPref.setChecked(PrefsManager.getBool(realPrefKey));
} else if (pref instanceof SwitchPreferenceCompat) {
pref.setKey("tmpKeyBool");
SwitchPreferenceCompat switchPref = (SwitchPreferenceCompat) pref;
switchPref.setChecked(PrefsManager.getBool(realPrefKey));
} else if (pref instanceof EditTextPreference) {
pref.setKey("tmpKeyString");
EditTextPreference editTextPref = (EditTextPreference) pref;
editTextPref.setText(PrefsManager.getString(realPrefKey));
} else if (pref instanceof ListPreference) {
pref.setKey("tmpKeyString");
ListPreference listPref = (ListPreference) pref;
listPref.setValue(PrefsManager.getString(realPrefKey));
}
pref.setPersistent(true);
pref.setKey(realPrefKey);
}
示例4: initSettings
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void initSettings(){
PreferenceScreen screen = getPreferenceScreen();
for(int i = 0; i < courses.size(); i++){
//Add all courses as a checkbox
CheckBoxPreference cbp = new CheckBoxPreference(getContext());
cbp.setPersistent(false);
cbp.setTitle(courses.get(i).getCourseCode());
cbp.setKey("" + courses.get(i).getId());
cbp.setViewId(i);
cbp.setOnPreferenceClickListener(this);
if (courses.get(i).isFavorite()) {
cbp.setChecked(true);
}
checkBoxes.add(cbp);
screen.addPreference(cbp);
}
}
示例5: checkForRoot
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void checkForRoot(
String key
) {
CheckBoxPreference p = (CheckBoxPreference) findPreference(key);
if (p == null) {
return;
}
if (p.isEnabled() && !Shell.SU.available()) {
p.setChecked(false);
SnackBarUtil.make(getActivity(), getString(R.string.root_not_available));
}
}
示例6: addAutoSyncProperty
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
protected void addAutoSyncProperty(
final IGISApplication application,
final Account account,
PreferenceGroup syncCategory)
{
final String accountNameHash = "_" + account.name.hashCode();
SharedPreferences sharedPreferences =
mStyledContext.getSharedPreferences(Constants.PREFERENCES,
Constants.MODE_MULTI_PROCESS);
CheckBoxPreference enablePeriodicSync = new CheckBoxPreference(mStyledContext);
enablePeriodicSync.setKey(KEY_SYNC);
enablePeriodicSync.setPersistent(false);
enablePeriodicSync.setTitle(R.string.auto_sync);
boolean isAccountSyncEnabled = isAccountSyncEnabled(account, application.getAuthority());
enablePeriodicSync.setChecked(isAccountSyncEnabled);
enablePeriodicSync.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(
Preference preference,
Object newValue)
{
boolean isChecked = (boolean) newValue;
setAccountSyncEnabled(account, application.getAuthority(), isChecked);
return true;
}
});
long timeStamp = sharedPreferences.getLong(
com.nextgis.maplib.util.SettingsConstants.KEY_PREF_LAST_SYNC_TIMESTAMP
+ accountNameHash, 0);
if (isAccountSyncEnabled && timeStamp > 0) {
enablePeriodicSync.setSummary(ControlHelper.getSyncTime(mStyledContext, timeStamp));
} else {
enablePeriodicSync.setSummary(R.string.auto_sync_summary);
}
syncCategory.addPreference(enablePeriodicSync);
}
示例7: onCreate
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Make sure default values are applied. In a real app, you would
// want this in a shared function that is used to retrieve the
// SharedPreferences wherever they are needed.
PreferenceManager.setDefaultValues(getActivity(),
R.xml.preference_app, false);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preference_app);
if (BuildConfig.FOSS_ONLY) {
// disable tracking if GA is not used
CheckBoxPreference trackingErrors = (CheckBoxPreference) findPreference(PreferenceWrapper.PREF_TRACKING_ERRORS);
trackingErrors.setEnabled(false);
trackingErrors.setChecked(false);
}
ListPreference mapFiles = (ListPreference) findPreference(PreferenceWrapper.PREF_MAP_FILE);
if (mapFiles != null) {
ArrayList<String> entries = new ArrayList<>();
ArrayList<String> entryValues = new ArrayList<>();
CollectMapFiles(entries, entryValues);
mapFiles.setEntries(entries.toArray(new CharSequence[entries.size()]));
mapFiles.setEntryValues(entryValues.toArray(new CharSequence[entryValues.size()]));
int index = Math
.max(mapFiles.findIndexOfValue(getPreferenceManager().getSharedPreferences().getString(
mapFiles.getKey(), "")), 0);
mapFiles.setValueIndex(index);
}
}
示例8: onSharedPreferenceChanged
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
handlePreferenceChange(findPreference(key), sharedPreferences, key);
final Preference preference = findPreference(key);
if (preference instanceof ListPreference) {
preference.setSummary(((ListPreference) preference).getEntry());
} else if (preference instanceof CheckBoxPreference) {
CheckBoxPreference checkPreference = (CheckBoxPreference) preference;
checkPreference.setChecked(sharedPreferences.getBoolean(key, false));
}
}
示例9: setOwnPlayAccount
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void setOwnPlayAccount(
boolean b
) {
CheckBoxPreference p = (CheckBoxPreference)findPreference(getString(R.string.preferences_play_own_account_key));
p.setChecked(b);
}
示例10: rollbackCheck
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void rollbackCheck(CheckBoxPreference preference) {
preference.setChecked(!preference.isChecked());
}