本文整理匯總了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;
}