本文整理汇总了Java中android.widget.CompoundButton.OnCheckedChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java CompoundButton.OnCheckedChangeListener方法的具体用法?Java CompoundButton.OnCheckedChangeListener怎么用?Java CompoundButton.OnCheckedChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.CompoundButton
的用法示例。
在下文中一共展示了CompoundButton.OnCheckedChangeListener方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkedButton
import android.widget.CompoundButton; //导入方法依赖的package包/类
public static void checkedButton(CompoundButton compoundButton, boolean checked) {
if (compoundButton == null) {
return;
}
if (compoundButton.isChecked() == checked) {
return;
}
CompoundButton.OnCheckedChangeListener onCheckedChangeListener =
(CompoundButton.OnCheckedChangeListener) Reflect.getMember(CompoundButton.class,
compoundButton, "mOnCheckedChangeListener");
compoundButton.setOnCheckedChangeListener(null);
compoundButton.setChecked(checked);
compoundButton.setOnCheckedChangeListener(onCheckedChangeListener);
}
示例2: addEvent
import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
public void addEvent(String type) {
super.addEvent(type);
if (type != null && type.equals(Constants.Event.CHANGE) && getHostView() != null) {
if (mListener == null) {
mListener = new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Map<String, Object> params = new HashMap<>(2);
params.put("value", isChecked);
Map<String, Object> domChanges = new HashMap<>();
Map<String, Object> attrsChanges = new HashMap<>();
attrsChanges.put("checked",Boolean.toString(isChecked));
domChanges.put("attrs",attrsChanges);
fireEvent(Constants.Event.CHANGE, params,domChanges);
}
};
}
getHostView().setOnCheckedChangeListener(mListener);
}
}
示例3: onCreate
import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting);
final Switch readClipboard = findViewById(R.id.read_clipboard);
final Switch autoCopy = findViewById(R.id.auto_copy);
final SharedPreferences preferences = getSharedPreferences("data", MODE_PRIVATE);
readClipboard.setChecked(preferences.getBoolean("read_clipboard", true));
autoCopy.setChecked(preferences.getBoolean("auto_copy", true));
CompoundButton.OnCheckedChangeListener listener = new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
preferences.edit()
.putBoolean("read_clipboard", readClipboard.isChecked())
.putBoolean("auto_copy", autoCopy.isChecked())
.apply();
}
};
readClipboard.setOnCheckedChangeListener(listener);
autoCopy.setOnCheckedChangeListener(listener);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT_WATCH) {
readClipboard.setCursorVisible(false);
}
}
示例4: ListBean
import android.widget.CompoundButton; //导入方法依赖的package包/类
public ListBean(int mItemType, String mImageUrl, String mText, String mValue, int mId, LatteDelegate mDelegate, CompoundButton.OnCheckedChangeListener mOnCheckedChangeListener) {
this.mItemType = mItemType;
this.mImageUrl = mImageUrl;
this.mText = mText;
this.mValue = mValue;
this.mId = mId;
this.mDelegate = mDelegate;
this.mOnCheckedChangeListener = mOnCheckedChangeListener;
}
示例5: newInstance
import android.widget.CompoundButton; //导入方法依赖的package包/类
public static SwitcherFragment newInstance(String title, String summary, boolean checked,
CompoundButton.OnCheckedChangeListener onCheckedChangeListener) {
SwitcherFragment fragment = new SwitcherFragment();
fragment.mTitle = title;
fragment.mSummary = summary;
fragment.mChecked = checked;
fragment.mOnCheckedChangeListener = onCheckedChangeListener;
return fragment;
}
示例6: setOnCheckedChangeListener
import android.widget.CompoundButton; //导入方法依赖的package包/类
public void setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener listener) {
mSwitch.setOnCheckedChangeListener(listener);
}
示例7: setOnCheckedChangeListener
import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
public MartianViewHolder setOnCheckedChangeListener(int viewId, CompoundButton.OnCheckedChangeListener listener) {
CompoundButton view = getView(viewId);
view.setOnCheckedChangeListener(listener);
return this;
}
示例8: onCreate
import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_light_settings);
s = (Switch) findViewById(R.id.active);
tp = (TimePicker) findViewById(R.id.lockTime);
tp2 = (TimePicker) findViewById(R.id.unlockTime);
database = FirebaseDatabase.getInstance();
lightSettingsRef = database.getReference("lightsettings");
lightSettingsRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.e("db", "dbok in lightsettings.java");
tp.setOnTimeChangedListener(null);
tp2.setOnTimeChangedListener(null);
s.setOnCheckedChangeListener(null);
tp.setCurrentHour(((Number) dataSnapshot.child("onH").getValue()).intValue());
tp.setCurrentMinute(((Number) dataSnapshot.child("onM").getValue()).intValue());
tp2.setCurrentHour(((Number) dataSnapshot.child("offH").getValue()).intValue());
tp2.setCurrentMinute(((Number) dataSnapshot.child("offM").getValue()).intValue());
s.setChecked((boolean) dataSnapshot.child("active").getValue());
tp.setOnTimeChangedListener(timePickerListener);
tp2.setOnTimeChangedListener(timePickerListener);
s.setOnCheckedChangeListener(switchListener);
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.e("db",databaseError.toString());
}
});
timePickerListener = new TimePicker.OnTimeChangedListener(){
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
Log.d("deb","activity.updatesettings");
lightSettingsRef.setValue(new LightSettingsHelper(
s.isChecked(),
tp.getCurrentHour(),
tp.getCurrentMinute(),
tp2.getCurrentHour(),
tp2.getCurrentMinute()
));
}
};
switchListener = new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
lightSettingsRef.setValue(new LightSettingsHelper(
s.isChecked(),
tp.getCurrentHour(),
tp.getCurrentMinute(),
tp2.getCurrentHour(),
tp2.getCurrentMinute()
));
}
};
tp.setOnTimeChangedListener(timePickerListener);
tp2.setOnTimeChangedListener(timePickerListener);
s.setOnCheckedChangeListener(switchListener);
}
示例9: setOnCheckedChangeListener
import android.widget.CompoundButton; //导入方法依赖的package包/类
public void setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener listener){
mSwitch.setOnCheckedChangeListener(listener);
}
示例10: setOnCheckedChangeListener
import android.widget.CompoundButton; //导入方法依赖的package包/类
/**
* Sets the on checked change listener of the iView.
*/
IViewHolder setOnCheckedChangeListener(int viewId, CompoundButton.OnCheckedChangeListener listener);
示例11: setOnCheckedChangeListener
import android.widget.CompoundButton; //导入方法依赖的package包/类
/**
* Sets the on checked change listener of the view.
*
* @param viewId The view id.
* @param listener The checked change listener of compound button.
* @return The BaseViewHolder for chaining.
*/
public BaseViewHolder setOnCheckedChangeListener(int viewId, CompoundButton.OnCheckedChangeListener listener) {
CompoundButton view = getView(viewId);
view.setOnCheckedChangeListener(listener);
return this;
}
示例12: setOnCheckedChangeListener
import android.widget.CompoundButton; //导入方法依赖的package包/类
/**
* Sets the on checked change listener of the view.
*
* @param viewId The view id.
* @param listener The checked change listener of compound button.
* @return The BaseViewHolder for chaining.
*/
public BaseViewHolder setOnCheckedChangeListener(@IdRes int viewId, CompoundButton.OnCheckedChangeListener listener) {
CompoundButton view = getView(viewId);
view.setOnCheckedChangeListener(listener);
return this;
}
示例13: onToggle
import android.widget.CompoundButton; //导入方法依赖的package包/类
/**
* @return function which assigns {@link android.widget.CompoundButton.OnCheckedChangeListener}
* to {@link CompoundButton}.
* @throws ClassCastException if current view is not a {@link CompoundButton}.
*/
public static BindingFunction onToggle(@Nullable CompoundButton.OnCheckedChangeListener listener) {
return view -> ((CompoundButton) view).setOnCheckedChangeListener(listener);
}