本文整理汇总了Java中android.widget.CompoundButton.setChecked方法的典型用法代码示例。如果您正苦于以下问题:Java CompoundButton.setChecked方法的具体用法?Java CompoundButton.setChecked怎么用?Java CompoundButton.setChecked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.CompoundButton
的用法示例。
在下文中一共展示了CompoundButton.setChecked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClick
import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
CompoundButton cb = (CompoundButton) v;
NewConditionItem item = (NewConditionItem) cb.getTag();
boolean refresh = item.parent.processSubItems(item, cb.isChecked());
cb.setChecked(item.selected);
if (refresh) {
setConditionItem(mRoot);
this.postDelayed(new Runnable() {
@Override
public void run() {
mController.confirm(SorterContainer.this);
}
}, 20);
}
}
示例2: 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);
}
示例3: onCheckedChanged
import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
public void onCheckedChanged(android.widget.CompoundButton v, boolean isChecked) {
int position = (Integer)v.getTag();
if(mSelected[position] != isChecked) {
mSelected[position] = isChecked;
if(mOnSelectionChangedListener != null)
mOnSelectionChangedListener.onSelectionChanged(position, mSelected[position]);
}
if(mMode == MODE_ITEMS && isChecked && mLastSelectedIndex != position){
mSelected[mLastSelectedIndex] = false;
if(mOnSelectionChangedListener != null)
mOnSelectionChangedListener.onSelectionChanged(mLastSelectedIndex, false);
CompoundButton child = (CompoundButton) mListView.getChildAt(mLastSelectedIndex - mListView.getFirstVisiblePosition());
if(child != null)
child.setChecked(false);
mLastSelectedIndex = position;
}
}
示例4: onCheckedChanged
import android.widget.CompoundButton; //导入方法依赖的package包/类
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
WeightPhoto photo = (WeightPhoto) buttonView.getTag();
if (!isChecked || !this.mSelect.contains(photo)) {
if (isChecked) {
int size = this.mSelect.size();
WeightPhotosActivity weightPhotosActivity = this.mActivity;
if (size >= 2) {
Helper.showToast((CharSequence) "最多选择两张图片");
buttonView.setChecked(false);
return;
}
}
if (isChecked) {
this.mSelect.add(photo);
} else {
this.mSelect.remove(photo);
}
this.mActivity.setSelectText();
}
}
示例5: setConditionItem
import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
public void setConditionItem(NewConditionItem item) {
mRoot = item;
mTvTitle.setText(item.name);
mGrid.removeAllViews();
for (NewConditionItem subItem : mRoot.subItems) {
if (subItem.type != NewConditionItem.TYPE_LIST) {
if (subItem.type == NewConditionItem.TYPE_DATA) {
this.item = (DateSelectConditionItem) subItem;
DataSelectContainer container2 = new DataSelectContainer(getContext());
LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
);
container2.setLayoutParams(lp2);
container2.setTag(subItem);
container2.setConditionItem(subItem);
addFooterView(container2);
}
continue;
}
btn = (CompoundButton) LayoutInflater.from(getContext())
.inflate(R.layout.item_condition_grid, mGrid, false);
btn.setTag(subItem);
btn.setText(subItem.name);
btn.setChecked(subItem.selected);
btn.setOnCheckedChangeListener(this);
addToGrid(btn);
}
}
示例6: onCheckedChanged
import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
NewConditionItem item = (NewConditionItem) buttonView.getTag();
boolean refresh = item.parent.processSubItems(item, buttonView.isChecked());
buttonView.setChecked(item.selected);
if (refresh) {
setConditionItem(item.parent);
}
}
示例7: onClick
import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
CompoundButton cb = (CompoundButton) v;
NewConditionItem item = (NewConditionItem) cb.getTag();
boolean refresh = item.parent.processSubItems(item, cb.isChecked());
cb.setChecked(item.selected);
if (refresh) {
setLv0Item(item.parent);
}
}
示例8: onCheckedChanged
import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) {
case R.id.v0:
if (isChecked) {
tempModel.selection = p;
adapter.notifyDataSetChanged();
}
break;
case R.id.v14:
if (isChecked) {
// 去除对应的临时要货勾选
if (tempModel.skus[p].checkTemp) {
tempModel.skus[p].checkTemp = false;
adapter.notifyDataSetChanged();
}
}
tempModel.skus[p].checkFormal = isChecked;
break;
case R.id.v15:
if (isChecked) {
if (mustTempReason(binding.getModel(), binding.v16.getText().toString())) {
buttonView.setChecked(false);
activity.showToast("必须填写临时要货原因");
return;
}
// 去除对应的正式要货勾选
if (tempModel.skus[p].checkFormal) {
tempModel.skus[p].checkFormal = false;
adapter.notifyDataSetChanged();
}
}
tempModel.skus[p].checkTemp = isChecked;
break;
}
}
示例9: onBindViewHolder
import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(RegionContainer.VH holder, final int position) {
final NewConditionItem item = mList.get(position);
if (holder.getItemViewType() == TYPE_EDIT) {
CompoundButton btnEdit = holder.tb;
btnEdit.setText(item.name);
btnEdit.setChecked(item.selected);
btnEdit.setTag(item);
btnEdit.setId(holder.getItemViewType());
btnEdit.setOnClickListener(mOnClickListener);
final View finalView = btnEdit;
final NewConditionItem finalitem =item;
btnEdit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mOnItemClickListener!= null) {
mOnItemClickListener.onEditClick(finalView, item.id);
}
}
});
} else {
CompoundButton btn = holder.tb;
btn.setText(item.name);
btn.setChecked(item.selected);
btn.setTag(item);
btn.setId(holder.getItemViewType());
btn.setOnClickListener(mOnClickListener);
}
}
示例10: setupView
import android.widget.CompoundButton; //导入方法依赖的package包/类
private void setupView(Cursor cursor, View view, CompoundButton switchView) {
final Repo repo = new Repo(cursor);
switchView.setChecked(repo.inuse);
// Add this listener *after* setting the checked status, so we don't
// invoke the listener while setting up the view...
switchView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (enabledListener != null) {
enabledListener.onSetEnabled(repo, isChecked);
}
}
});
TextView nameView = (TextView) view.findViewById(R.id.repo_name);
nameView.setText(repo.getName());
View unsignedView = view.findViewById(R.id.repo_unsigned);
View unverifiedView = view.findViewById(R.id.repo_unverified);
if (repo.isSigned()) {
unsignedView.setVisibility(View.GONE);
unverifiedView.setVisibility(View.GONE);
} else if (repo.isSignedButUnverified()) {
unsignedView.setVisibility(View.GONE);
unverifiedView.setVisibility(View.VISIBLE);
} else {
unsignedView.setVisibility(View.VISIBLE);
unverifiedView.setVisibility(View.GONE);
}
}
示例11: setChecked
import android.widget.CompoundButton; //导入方法依赖的package包/类
public void setChecked(boolean checked) {
CompoundButton compoundButton;
if (this.mItemData.isExclusiveCheckable()) {
if (this.mRadioButton == null) {
insertRadioButton();
}
compoundButton = this.mRadioButton;
} else {
if (this.mCheckBox == null) {
insertCheckBox();
}
compoundButton = this.mCheckBox;
}
compoundButton.setChecked(checked);
}
示例12: mapReflectedData
import android.widget.CompoundButton; //导入方法依赖的package包/类
private void mapReflectedData(String key, T item, DataMapping<T> mapping, AttributeMapping<T> viewMapping, View targetView)
{
targetView.setVisibility(View.VISIBLE);
Object result = null;
if (key == null) {
result = item; //Item is itself's value.
}
else {
result = ReflectionHelper.getAttribute(item, mapping.realClass, key);
}
if (result == null) {
result = viewMapping.fallback;
}
if (result == null || (result != null && result.equals(viewMapping.invalid))) {
//Item and it's fallback are null or the item is invalid.
targetView.setVisibility(viewMapping.visibilityIfNoData);
}
else if (targetView instanceof CompoundButton) {
CompoundButton checkable = (CompoundButton)targetView;
checkable.setChecked((Boolean)result);
}
else if (targetView instanceof TextView) {
((TextView)targetView).setText(result.toString());
}
else if (targetView instanceof ImageView) {
if (result instanceof CharSequence) {
((ImageView)targetView).setImageURI(Uri.parse(result.toString()));
}
else {
((ImageView)targetView).setImageResource((Integer)result);
}
}
else {
throw new RuntimeException("Unknown view type for key: " + key);
}
}
示例13: onCheckedChanged
import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
setChecking();
compoundButton.setChecked(true);
switch (compoundButton.getId()){
case R.id.radioButton1:
builder.setType(TextCounter.BYTE);
seekBar1.setEnabled(false);
type = TextCounter.BYTE;
break;
case R.id.radioButton2:
builder.setType(TextCounter.SHORT);
seekBar1.setEnabled(false);
type = TextCounter.SHORT;
break;
case R.id.radioButton3:
builder.setType(TextCounter.INT);
seekBar1.setEnabled(false);
type = TextCounter.INT;
break;
case R.id.radioButton4:
builder.setType(TextCounter.FLOAT);
seekBar1.setEnabled(true);
type = TextCounter.FLOAT;
break;
case R.id.radioButton5:
builder.setType(TextCounter.LONG);
seekBar1.setEnabled(false);
type = TextCounter.LONG;
break;
case R.id.radioButton6:
builder.setType(TextCounter.DOUBLE);
seekBar1.setEnabled(true);
type = TextCounter.DOUBLE;
break;
default:
return;
}
}
示例14: doOnlyCheckedOne
import android.widget.CompoundButton; //导入方法依赖的package包/类
public void doOnlyCheckedOne(String item) {
for (int i = 0; i < getChildCount(); i++) {
CompoundButton button = (CompoundButton) getChildAt(i);
if (button.getText().toString().equals(item)) {
button.setChecked(true);
button.setTextColor(config.buttonSelectedTextColor);
} else {
button.setChecked(false);
button.setTextColor(config.buttonTextColor);
}
}
}
示例15: doNotCheckedOne
import android.widget.CompoundButton; //导入方法依赖的package包/类
public void doNotCheckedOne(String item) {
for (int i = 0; i < getChildCount(); i++) {
CompoundButton button = (CompoundButton) getChildAt(i);
if (button.getText().toString().equals(item)) {
button.setChecked(false);
button.setTextColor(config.buttonTextColor);
}
}
}