本文整理汇总了Java中android.support.v7.widget.SwitchCompat类的典型用法代码示例。如果您正苦于以下问题:Java SwitchCompat类的具体用法?Java SwitchCompat怎么用?Java SwitchCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SwitchCompat类属于android.support.v7.widget包,在下文中一共展示了SwitchCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initAnimation
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
private void initAnimation(View view) {
mSimpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
mSimpleDraweeView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setOldController(mSimpleDraweeView.getController())
.setUri(URI_KEYFRAMES_ANIMATION)
.setAutoPlayAnimations(true)
.build();
mSimpleDraweeView.setController(controller);
final SwitchCompat switchBackground = (SwitchCompat) view.findViewById(R.id.switch_background);
switchBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mSimpleDraweeView.getHierarchy().setBackgroundImage(isChecked
? new CheckerBoardDrawable(getResources())
: null);
}
});
}
示例2: onCreate
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_settings);
showID = getIntent().getIntExtra("showID", 0);
notificationSwitch = (SwitchCompat) findViewById(R.id.notification_switch);
updateImagesSwitch = (SwitchCompat) findViewById(R.id.update_images_switch);
posterTV = (TextView) findViewById(R.id.tv_poster);
bannerTV = (TextView) findViewById(R.id.tv_banner);
fanArtTV = (TextView) findViewById(R.id.tv_fanart);
updateImagesLayout = (RelativeLayout) findViewById(R.id.update_images);
notificationTimeLayout = (LinearLayout) findViewById(R.id.notification_time);
notificationTimeTV = (TextView) findViewById(R.id.tv_notification_time);
notificationViewPopulate();
notificationSwitchListener();
imagesSwitchListener();
viewListeners();
}
示例3: uiInitBluetooth
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
private void uiInitBluetooth() {
if (bluetooth != null) {
textBluetoothVisible = (TextView) findViewById(R.id.bluetooth_visible);
viewBluetoothId = (TextView) findViewById(R.id.device_id_bluetooth);
viewBluetoothId.setText(bluetooth.getName());
viewBluetoothId.setVisibility(bluetooth.isEnabled() ? View.VISIBLE : View.GONE);
int textResource = getManager().isBluetoothDiscoverable() ? R.string.swap_visible_bluetooth : R.string.swap_not_visible_bluetooth;
textBluetoothVisible.setText(textResource);
bluetoothSwitch = (SwitchCompat) findViewById(R.id.switch_bluetooth);
Utils.debugLog(TAG, getManager().isBluetoothDiscoverable() ? "Initially marking switch as checked, because Bluetooth is discoverable." : "Initially marking switch as not-checked, because Bluetooth is not discoverable.");
bluetoothSwitch.setOnCheckedChangeListener(onBluetoothSwitchToggled);
setBluetoothSwitchState(getManager().isBluetoothDiscoverable(), true);
LocalBroadcastManager.getInstance(getContext()).registerReceiver(onBluetoothSwapStateChanged, new IntentFilter(SwapService.BLUETOOTH_STATE_CHANGE));
} else {
findViewById(R.id.bluetooth_info).setVisibility(View.GONE);
}
}
示例4: onActivityResult
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.M)
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
SwitchCompat switchshutdowncountdown = (SwitchCompat) findViewById(R.id.switchshutdowncountdown);
if (requestCode == REQUEST_CODE) {
if (android.provider.Settings.canDrawOverlays(Settings_Activity.this)) {
// continue here - permission was granted
settingsprefs.edit().putBoolean("sysOverlay", true).apply();
switchshutdowncountdown.setChecked(true);
} else {
settingsprefs.edit().putBoolean("sysOverlay", false).apply();
switchshutdowncountdown.setChecked(false);
}
} else if (requestCode == REQUEST_CODE_ENABLE) {
settingsprefs.edit().putBoolean("pinprotection", true).apply();
changepin.setVisibility(View.VISIBLE);
changepindivider.setVisibility(View.VISIBLE);
}
}
示例5: initView
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
@Override
public void initView() {
headerLayout = (RelativeLayout) findViewById(R.id.rl_setting_header);
account = (TextView) findViewById(R.id.tv_setting_account);
nick = (TextView) findViewById(R.id.tv_tv_setting_nick);
avatar = (RoundAngleImageView) findViewById(R.id.riv_setting_avatar);
RelativeLayout notificationLayout = (RelativeLayout) findViewById(R.id.rl_setting_notification);
((TextView) notificationLayout.findViewById(R.id.tv_setting_item_title)).setText("通知提醒");
notification = (SwitchCompat) findViewById(R.id.switch_setting_item_check);
clear = (LinearLayout) findViewById(R.id.ll_setting_clear);
((TextView) clear.findViewById(R.id.tv_group_info_item_layout_title)).setText("清空所有的聊天记录");
chatFlow = (TextView) clear.findViewById(R.id.tv_group_info_item_layout_value);
logout = (Button) findViewById(R.id.btn_setting_logout);
headerLayout.setOnClickListener(this);
clear.setOnClickListener(this);
logout.setOnClickListener(this);
notification.setOnCheckedChangeListener(this);
}
示例6: onCreateOptionsMenu
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu (Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
MenuItem item = menu.findItem(R.id.action_enable);
item.setActionView(R.layout.switch_layout);
SwitchCompat mSwitchEnablePush = item.getActionView().findViewById(R.id.switchForActionBar);
mSwitchEnablePush.setChecked(PushController.isAllEnable(this));
mSwitchEnablePush.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
PushController.setAllEnable(b, MainActivity.this);
Toast.makeText(MainActivity.this,
b ? R.string.msg_enable : R.string.msg_disable
, Toast.LENGTH_SHORT).show();
}
});
return true;
}
示例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 ("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);
}
}
示例8: onCreateView
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_apply_on_boot, container, false);
((TextView) rootView.findViewById(R.id.title)).setText(getString(R.string.profile_tasker_toast));
SwitchCompat switchCompat = (SwitchCompat) rootView.findViewById(R.id.switcher);
switchCompat.setChecked(Prefs.getBoolean("showtaskertoast", true, getActivity()));
switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
Prefs.saveBoolean("showtaskertoast", b, getActivity());
}
});
return rootView;
}
示例9: onOptionsChanged
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
@Override
public void onOptionsChanged() {
if (mNativeTranslateInfoBarPtr == 0) return;
// Handle the "Always Translate" checkbox.
if (getInfoBarType() == AFTER_TRANSLATE_INFOBAR) {
SwitchCompat alwaysSwitch = (SwitchCompat) getView().findViewById(
R.id.translate_infobar_always_toggle);
mOptions.toggleAlwaysTranslateLanguageState(alwaysSwitch.isChecked());
}
if (mOptions.optionsChanged()) {
nativeApplyTranslateOptions(mNativeTranslateInfoBarPtr, mOptions.sourceLanguageCode(),
mOptions.targetLanguageCode(), mOptions.alwaysTranslateLanguageState(),
mOptions.neverTranslateLanguageState(), mOptions.neverTranslateDomainState());
}
}
示例10: convert
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
@Override
protected void convert(BaseViewHolder helper, ListBean item) {
switch (helper.getItemViewType()) {
case ListItemType.ITEM_NORMAL:
helper.setText(R.id.tv_arrow_text, item.getText());
helper.setText(R.id.tv_arrow_value, item.getValue());
break;
case ListItemType.ITEM_AVATAR:
Glide.with(mContext)
.load(item.getImageUrl())
.diskCacheStrategy(DiskCacheStrategy.ALL).centerCrop().dontAnimate()
.into((ImageView) helper.getView(R.id.img_arrow_avatar));
break;
case ListItemType.ITEM_SWITCH:
helper.setText(R.id.tv_arrow_switch_text,item.getText());
final SwitchCompat switchCompat = helper.getView(R.id.list_item_switch);
switchCompat.setChecked(true);
switchCompat.setOnCheckedChangeListener(item.getOnCheckedChangeListener());
break;
}
}
示例11: onCreateOptionsMenu
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_switch, menu);
// Get the action view used in your toggleservice item
final MenuItem toggle = menu.findItem(R.id.menu_switch);
mSwitch = (SwitchCompat) toggle.getActionView().findViewById(R.id.switchInActionBar);
mSwitch.setEnabled(mTransportIdEditText.length() > 0 && mEmailEditText.length() > 0 &&
mPasswordEditText.length() > 0);
mSwitch.setChecked(mStartButton.getVisibility() != View.VISIBLE);
mSwitch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (((SwitchCompat) v).isChecked()) {
checkInputFields();
} else {
confirmStop();
}
}
});
return super.onCreateOptionsMenu(menu);
}
示例12: setTint
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
public static void setTint(@NonNull SwitchCompat switchView, @ColorInt int color, boolean useDarker) {
if (switchView.getTrackDrawable() != null) {
switchView.setTrackDrawable(modifySwitchDrawable(switchView.getContext(),
switchView.getTrackDrawable(), color, false, true, useDarker));
}
if (switchView.getThumbDrawable() != null) {
switchView.setThumbDrawable(modifySwitchDrawable(switchView.getContext(),
switchView.getThumbDrawable(), color, true, true, useDarker));
}
}
示例13: initView
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
@Override
protected void initView(Bundle bundle) {
super.initView(bundle);
GlideManager.loadCircleImg("https://avatars3.githubusercontent.com/u/19605922?v=4&s=460", ivHead);
titleBarDrawer.setImmersible(mContext, isImmersible, isLight);
vHeader = View.inflate(mContext, R.layout.layout_title_header, null);
sBtnImmersible = (SwitchCompat) vHeader.findViewById(R.id.sBtn_immersible);
sBtnLight = (SwitchCompat) vHeader.findViewById(R.id.sBtn_light);
sBtnLine = (SwitchCompat) vHeader.findViewById(R.id.sBtn_line);
lLayoutAlpha = (LinearLayout) vHeader.findViewById(R.id.lLayout_alpha);
sBarAlpha = (SeekBar) vHeader.findViewById(R.id.sBar_alpha);
tvStatusAlpha = (TextView) vHeader.findViewById(R.id.tv_statusAlpha);
initView();
setDrawerList();
initData();
}
示例14: initView
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
@Override
protected void initView(Bundle bundle) {
super.initView(bundle);
// drawerRoot.setScrimColor(0x00ffffff);//背景高亮
// drawerRoot.setDrawerElevation(40);//海拔高度
mContentView.setBackgroundDrawable(null);
GlideManager.loadCircleImg("https://avatars3.githubusercontent.com/u/19605922?v=4&s=460", ivHead);
titleBarDrawer.setImmersible(mContext, isImmersible, isLight);
vHeader = View.inflate(mContext, R.layout.layout_title_header, null);
sBtnImmersible = (SwitchCompat) vHeader.findViewById(R.id.sBtn_immersible);
sBtnLight = (SwitchCompat) vHeader.findViewById(R.id.sBtn_light);
sBtnLine = (SwitchCompat) vHeader.findViewById(R.id.sBtn_line);
lLayoutAlpha = (LinearLayout) vHeader.findViewById(R.id.lLayout_alpha);
sBarAlpha = (SeekBar) vHeader.findViewById(R.id.sBar_alpha);
tvStatusAlpha = (TextView) vHeader.findViewById(R.id.tv_statusAlpha);
initView();
setDrawerList();
initData();
}
示例15: initVariables
import android.support.v7.widget.SwitchCompat; //导入依赖的package包/类
private void initVariables() {
thisActivity = this;
localIPText = findViewById(R.id.my_local_ip);
externalIPText = findViewById(R.id.my_external_ip);
statusText = findViewById(R.id.status);
statusText.setMovementMethod(new ScrollingMovementMethod());
sendButton = (Button) findViewById(R.id.send_button);
messageEditText = (EditText) findViewById(R.id.message_edit_text);
extraInformationPanel = (LinearLayout) findViewById(R.id.extra_information_panel);
developerModeText = (TextView) findViewById(R.id.developer_mode_text);
switchDeveloperMode = (SwitchCompat) findViewById(R.id.switch_developer_mode);
switchDeveloperMode.setOnCheckedChangeListener(this);
editTextDestinationIP = findViewById(R.id.destination_IP);
editTextDestinationPort = findViewById(R.id.destination_port);
}