本文整理汇总了Java中android.support.v7.widget.SwitchCompat.isChecked方法的典型用法代码示例。如果您正苦于以下问题:Java SwitchCompat.isChecked方法的具体用法?Java SwitchCompat.isChecked怎么用?Java SwitchCompat.isChecked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.SwitchCompat
的用法示例。
在下文中一共展示了SwitchCompat.isChecked方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSharedPreferenceChanged
import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String name) {
Log.i(TAG, "Preference " + name + "=" + prefs.getAll().get(name));
if ("log".equals(name)) {
// Get enabled
boolean log = prefs.getBoolean(name, false);
// Display disabled warning
TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled);
tvDisabled.setVisibility(log ? View.GONE : View.VISIBLE);
// Check switch state
SwitchCompat swEnabled = (SwitchCompat) getSupportActionBar().getCustomView().findViewById(R.id.swEnabled);
if (swEnabled.isChecked() != log)
swEnabled.setChecked(log);
ServiceSinkhole.reload("changed " + name, ActivityLog.this);
}
}
示例2: onSideSwitch
import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
public void onSideSwitch(SwitchCompat v) {
Rect rect = new Rect();
v.getGlobalVisibleRect(rect);
final int cy = rect.centerY();
final int halfThumbWidth = v.getThumbDrawable().getIntrinsicWidth() / 2;
final int cx;
if (this instanceof DayModeFragment && v.isChecked()) {
cx = rect.right - halfThumbWidth;
mThemeActivity.switchModeFragment(cx, cy, isAppBarExpanded(), NightModeFragment.TAG);
} else if (!v.isChecked()) {
cx = rect.left + halfThumbWidth;
mThemeActivity.switchModeFragment(cx, cy, isAppBarExpanded(), DayModeFragment.TAG);
}
}
示例3: isPersistSwitchOn
import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
/**
* Returns true if the persist switch exists and is toggled on.
*/
@CalledByNative
protected boolean isPersistSwitchOn() {
SwitchCompat persistSwitch = (SwitchCompat) getView().findViewById(
R.id.permission_infobar_persist_toggle);
if (mShowPersistenceToggle && persistSwitch != null) {
return persistSwitch.isChecked();
}
return false;
}
示例4: saveProject
import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
@Override
public void saveProject(EditText project_name, SwitchCompat is_archived) {
if (is_archived.isChecked()) {
project.setState(1);
} else {
project.setState(0);
}
project.setName(project_name.getText().toString());
project.save();
}
示例5: onSharedPreferenceChanged
import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String name) {
Log.i(TAG, "Preference " + name + "=" + prefs.getAll().get(name));
if ("enabled".equals(name)) {
// Get enabled
boolean enabled = prefs.getBoolean(name, false);
// Check switch state
SwitchCompat swEnabled = (SwitchCompat) getSupportActionBar().getCustomView().findViewById(R.id.swEnabled);
if (swEnabled.isChecked() != enabled)
swEnabled.setChecked(enabled);
}
}
示例6: userDesiresSend
import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
@Nullable
@Override
public TCMPMessage userDesiresSend(View parameterViewParent) {
SwitchCompat continuousSwitch = ButterKnife.findById(parameterViewParent,R.id.sw_continuous);
SeekBar seekBar = ButterKnife.findById(parameterViewParent,R.id.seeker_polling_time);
boolean isContinuous = continuousSwitch.isChecked();
int timeValue = seekBar.getProgress() + 1;
timeValue = timeValue == 11 ? 0: timeValue;
return command.getMessage((byte)timeValue,isContinuous);
}
示例7: onSharedPreferenceChanged
import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String name) {
Log.i(TAG, "Preference " + name + "=" + prefs.getAll().get(name));
if ("enabled".equals(name)) {
// Get enabled
boolean enabled = prefs.getBoolean(name, false);
// Display disabled warning
TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled);
tvDisabled.setVisibility(enabled ? View.GONE : View.VISIBLE);
// Check switch state
SwitchCompat swEnabled = (SwitchCompat) getSupportActionBar().getCustomView().findViewById(R.id.swEnabled);
if (swEnabled.isChecked() != enabled)
swEnabled.setChecked(enabled);
} else if ("whitelist_wifi".equals(name) ||
"screen_on".equals(name) ||
"screen_wifi".equals(name) ||
"whitelist_other".equals(name) ||
"screen_other".equals(name) ||
"whitelist_roaming".equals(name) ||
"show_user".equals(name) ||
"show_system".equals(name) ||
"show_nointernet".equals(name) ||
"show_disabled".equals(name) ||
"sort".equals(name) ||
"imported".equals(name)) {
updateApplicationList(null);
final LinearLayout llWhitelist = (LinearLayout) findViewById(R.id.llWhitelist);
boolean screen_on = prefs.getBoolean("screen_on", true);
boolean whitelist_wifi = prefs.getBoolean("whitelist_wifi", false);
boolean whitelist_other = prefs.getBoolean("whitelist_other", false);
boolean hintWhitelist = prefs.getBoolean("hint_whitelist", true);
llWhitelist.setVisibility(!(whitelist_wifi || whitelist_other) && screen_on && hintWhitelist ? View.VISIBLE : View.GONE);
} else if ("manage_system".equals(name)) {
invalidateOptionsMenu();
updateApplicationList(null);
LinearLayout llSystem = (LinearLayout) findViewById(R.id.llSystem);
boolean system = prefs.getBoolean("manage_system", false);
boolean hint = prefs.getBoolean("hint_system", true);
llSystem.setVisibility(!system && hint ? View.VISIBLE : View.GONE);
} else if ("theme".equals(name) || "dark_theme".equals(name))
recreate();
}
示例8: onSharedPreferenceChanged
import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String name) {
Log.i(TAG, "Preference " + name + "=" + prefs.getAll().get(name));
if ("enabled".equals(name)) {
// Get enabled
boolean enabled = prefs.getBoolean(name, false);
// Display disabled warning
TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled);
tvDisabled.setVisibility(enabled ? View.GONE : View.VISIBLE);
// Check switch state
SwitchCompat swEnabled = (SwitchCompat) getSupportActionBar().getCustomView().findViewById(R.id.swEnabled);
if (swEnabled.isChecked() != enabled)
swEnabled.setChecked(enabled);
} else if ("whitelist_wifi".equals(name) ||
"screen_wifi".equals(name) ||
"whitelist_other".equals(name) ||
"screen_other".equals(name) ||
"whitelist_roaming".equals(name) ||
"show_user".equals(name) ||
"show_system".equals(name) ||
"show_nointernet".equals(name) ||
"show_disabled".equals(name) ||
"sort".equals(name) ||
"imported".equals(name)) {
updateApplicationList(null);
final LinearLayout llWhitelist = (LinearLayout) findViewById(R.id.llWhitelist);
boolean whitelist_wifi = prefs.getBoolean("whitelist_wifi", false);
boolean whitelist_other = prefs.getBoolean("whitelist_other", false);
boolean hintWhitelist = prefs.getBoolean("hint_whitelist", true);
llWhitelist.setVisibility(!(whitelist_wifi || whitelist_other) && hintWhitelist ? View.VISIBLE : View.GONE);
} else if ("manage_system".equals(name)) {
invalidateOptionsMenu();
updateApplicationList(null);
LinearLayout llSystem = (LinearLayout) findViewById(R.id.llSystem);
boolean system = prefs.getBoolean("manage_system", false);
boolean hint = prefs.getBoolean("hint_system", true);
llSystem.setVisibility(!system && hint ? View.VISIBLE : View.GONE);
} else if ("theme".equals(name) || "dark_theme".equals(name))
recreate();
}
示例9: uncheckSwitchIfChecked
import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
private void uncheckSwitchIfChecked(SwitchCompat switchCompat) {
if (switchCompat.isChecked()) {
switchCompat.setChecked(false);
}
}
示例10: getStatus
import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
/**
* Tells us whether or not the switch says the light is currently on or not.
*
* @param buttonSwitch the switch we want to check the status on
* @return ON if the switch is currently on, OFF otherwise
*/
@VisibleForTesting
protected Executor.LoadStatus getStatus(SwitchCompat buttonSwitch) {
return buttonSwitch.isChecked() ? Executor.LoadStatus.ON : Executor.LoadStatus.OFF;
}