本文整理汇总了Java中android.widget.RadioButton.isChecked方法的典型用法代码示例。如果您正苦于以下问题:Java RadioButton.isChecked方法的具体用法?Java RadioButton.isChecked怎么用?Java RadioButton.isChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RadioButton
的用法示例。
在下文中一共展示了RadioButton.isChecked方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addView
import android.widget.RadioButton; //导入方法依赖的package包/类
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
if (child instanceof RadioButton) {
final RadioButton button = (RadioButton) child;
radioButtons.add(button);
if (button.isChecked()) {
mProtectFromCheckedChange = true;
if (mCheckedId != -1) {
setCheckedStateForView(mCheckedId, false);
}
mProtectFromCheckedChange = false;
setCheckedId(button.getId());
}
} else if (child instanceof ViewGroup) {// 如果是复合控件
// 遍历复合控件
ViewGroup vg = ((ViewGroup) child);
setCheckedView(vg);
}
super.addView(child, index, params);
}
示例2: setCheckedView
import android.widget.RadioButton; //导入方法依赖的package包/类
/** 查找复合控件并设置radiobutton */
private void setCheckedView(ViewGroup vg) {
int len = vg.getChildCount();
for (int i = 0; i < len; i++) {
if (vg.getChildAt(i) instanceof RadioButton) {// 如果找到了,就设置check状态
final RadioButton button = (RadioButton) vg.getChildAt(i);
// 添加到容器
radioButtons.add(button);
if (button.isChecked()) {
mProtectFromCheckedChange = true;
if (mCheckedId != -1) {
setCheckedStateForView(mCheckedId, false);
}
mProtectFromCheckedChange = false;
setCheckedId(button.getId());
}
} else if (vg.getChildAt(i) instanceof ViewGroup) {// 迭代查找并设置
ViewGroup childVg = (ViewGroup) vg.getChildAt(i);
setCheckedView(childVg);
}
}
}
示例3: addView
import android.widget.RadioButton; //导入方法依赖的package包/类
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
if (child instanceof RadioButton) {
final RadioButton button = (RadioButton) child;
if (button.isChecked()) {
mProtectFromCheckedChange = true;
if (mCheckedId != -1) {
setCheckedStateForView(mCheckedId, false);
}
mProtectFromCheckedChange = false;
setCheckedId(button.getId());
}
}
super.addView(child, index, params);
}
示例4: addView
import android.widget.RadioButton; //导入方法依赖的package包/类
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
List<RadioButton> buttons = getAllRadioButton(child);
if(buttons != null && buttons.size() > 0){
for(RadioButton button : buttons){
if (button.isChecked()) {
mProtectFromCheckedChange = true;
if (mCheckedId != -1) {
setCheckedStateForView(mCheckedId, false);
}
mProtectFromCheckedChange = false;
setCheckedId(button.getId());
}
}
}
super.addView(child, index, params);
}
示例5: onRadioButtonClicked
import android.widget.RadioButton; //导入方法依赖的package包/类
@OnClick({ R.id.rd_home, R.id.rd_features,R.id.rd_me }) public void onRadioButtonClicked(RadioButton radioButton) {
boolean checked = radioButton.isChecked();
switch (radioButton.getId()) {
case R.id.rd_home:
if (checked) {
fUtil.show(mFragments.get(0));break;
}
case R.id.rd_features:
if (checked) {
fUtil.show(mFragments.get(1));break;
}
case R.id.rd_me:
if (checked) {
fUtil.show(mFragments.get(2));break;
}
}
}
示例6: setChecked
import android.widget.RadioButton; //导入方法依赖的package包/类
@BindingAdapter({"checked", "model"})
public static <T> void setChecked(RadioButton radioButton, final ObservableField<T> checked, final T model) {
if (checked == null) {
return;
}
radioButton.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
if ((checked.get() == null || !checked.get().equals(model))
&& isChecked) {
checked.set(model);
}
});
final T checkedModel = checked.get();
final boolean shouldBeChecked = checkedModel != null && checkedModel.equals(model);
if (shouldBeChecked != radioButton.isChecked()) {
radioButton.setChecked(shouldBeChecked);
}
}
示例7: postInfo
import android.widget.RadioButton; //导入方法依赖的package包/类
private void postInfo() {
if (mAuthTask != null) {
return;
}
showProgress(true);
String payPath = "";
RadioButton zhifubao = (RadioButton)findViewById(R.id.zhifubao);
RadioButton wechat = (RadioButton)findViewById(R.id.wechat);
if (zhifubao.isChecked()){
payPath = "zhifubao";
} else if (wechat.isChecked()) {
payPath="wechat";
}
SharedPreferences sp = getSharedPreferences("now_account", Context.MODE_PRIVATE);
stuNum=sp.getString("now_stu_num",null);
Bundle bundle = getIntent().getExtras();
mAuthTask = new PostTask(bundle.getString("money"),bundle.getString("name"),
bundle.getString("phone"),bundle.getString("num"),bundle.getString("packsort"),
bundle.getString("pickupplace"),bundle.getString("delieverplace"),
bundle.getString("pickuptime"),bundle.getString("delievertime"),
payPath,bundle.getString("remark"),stuNum,bundle.getString("securitymoney"));
mAuthTask.execute((Void) null);
}
示例8: onRadioButtonClicked
import android.widget.RadioButton; //导入方法依赖的package包/类
/**
* onClick handler for radio buttons.
*/
public void onRadioButtonClicked(View view) {
int newSize;
RadioButton rb = (RadioButton) view;
if (!rb.isChecked()) {
Log.d(TAG, "Got click on non-checked radio button");
return;
}
switch (rb.getId()) {
case R.id.surfaceSizeTiny_radio:
newSize = SURFACE_SIZE_TINY;
break;
case R.id.surfaceSizeSmall_radio:
newSize = SURFACE_SIZE_SMALL;
break;
case R.id.surfaceSizeMedium_radio:
newSize = SURFACE_SIZE_MEDIUM;
break;
case R.id.surfaceSizeFull_radio:
newSize = SURFACE_SIZE_FULL;
break;
default:
throw new RuntimeException("Click from unknown id " + rb.getId());
}
mSelectedSize = newSize;
int[] wh = mWindowWidthHeight[newSize];
// Update the Surface size. This causes a "surface changed" event, but does not
// destroy and re-create the Surface.
SurfaceView sv = (SurfaceView) findViewById(R.id.hardwareScaler_surfaceView);
SurfaceHolder sh = sv.getHolder();
Log.d(TAG, "setting size to " + wh[0] + "x" + wh[1]);
sh.setFixedSize(wh[0], wh[1]);
}
示例9: onRadioButtonClicked
import android.widget.RadioButton; //导入方法依赖的package包/类
/**
* onClick handler for radio buttons.
*/
public void onRadioButtonClicked(View view) {
RadioButton rb = (RadioButton) view;
if (!rb.isChecked()) {
Log.d(TAG, "Got click on non-checked radio button");
return;
}
switch (rb.getId()) {
case R.id.recDrawTwice_radio:
mSelectedRecordMethod = RECMETHOD_DRAW_TWICE;
break;
case R.id.recFbo_radio:
mSelectedRecordMethod = RECMETHOD_FBO;
break;
case R.id.recFramebuffer_radio:
mSelectedRecordMethod = RECMETHOD_BLIT_FRAMEBUFFER;
break;
default:
throw new RuntimeException("Click from unknown id " + rb.getId());
}
Log.d(TAG, "Selected rec mode " + mSelectedRecordMethod);
RenderHandler rh = mRenderThread.getHandler();
if (rh != null) {
rh.setRecordMethod(mSelectedRecordMethod);
}
}
示例10: checkClick
import android.widget.RadioButton; //导入方法依赖的package包/类
public void checkClick(View v) {
RadioButton rb = (RadioButton) v;
if (rb.isChecked()) {
findViewById(R.id.btnNext).setEnabled(true);
findViewById(R.id.btnNext).setBackgroundColor(getResources().getColor(R.color.bar_color));
} else {
findViewById(R.id.btnNext).setEnabled(false);
findViewById(R.id.btnNext).setBackgroundColor(getResources().getColor(R.color.pickerview_wheelview_textcolor_divider));
}
}
示例11: selectPayChannle
import android.widget.RadioButton; //导入方法依赖的package包/类
public void selectPayChannle(String paychannel){
for (Map.Entry<String,RadioButton> entry:channels.entrySet()){
payChannel = paychannel;
RadioButton rb = entry.getValue();
if(entry.getKey().equals(paychannel)){
boolean isCheck = rb.isChecked();
rb.setChecked(!isCheck);
}
else
rb.setChecked(false);
}
}
示例12: setResult
import android.widget.RadioButton; //导入方法依赖的package包/类
void setResult() {
EditText et = (EditText)findViewById(R.id.age);
String checkEmpty = et.getText().toString();
RadioGroup rg = (RadioGroup)findViewById(R.id.gender);
RadioGroup rg2 = (RadioGroup)findViewById(R.id.reoccur);
RadioButton rb1 = (RadioButton)findViewById(R.id.male);
RadioButton rb2 = (RadioButton)findViewById(R.id.yes);
NumberPicker numberPicker = (NumberPicker) findViewById(R.id.numberPicker);
NumberPicker stringPicker = (NumberPicker) findViewById(R.id.stringPicker);
Intent intent = new Intent();
if (checkEmpty.matches("")){
Toast.makeText(AgeScreen.this, "Age not set!",
Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED, intent);
} else if (rg.getCheckedRadioButtonId() == -1) {
Toast.makeText(AgeScreen.this, "Gender not selected!",
Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED, intent);
} else if (rg2.getCheckedRadioButtonId() == -1) {
Toast.makeText(AgeScreen.this, "Recurrence not selected!",
Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED, intent);
} else {
//age
intent.putExtra("age",Integer.parseInt(checkEmpty));
//gender
if (rb1.isChecked())
intent.putExtra("gender","male");
else
intent.putExtra("gender","female");
//reoccurring
if (rb2.isChecked())
intent.putExtra("reoccurring",true);
else
intent.putExtra("reoccurring",false);
//days
int days = numberPicker.getValue();
int date = stringPicker.getValue();
if (date == 2)
days *= 28; //months selected
else if (date == 3)
days *= 365; //years selected
intent.putExtra("days",days);
setResult(RESULT_OK, intent);
}
finish();
}
示例13: onSaveClicked
import android.widget.RadioButton; //导入方法依赖的package包/类
public void onSaveClicked(View v) {
Log.d(TAG, "Save clicked");
MyApplication mApplication = (MyApplication) getApplicationContext();
RadioButton rbUpload = (RadioButton) findViewById(R.id.radioButtonUploadGlobal);
RadioButton rbExperiment = (RadioButton) findViewById(R.id.radioButtonUploadExperiment);
EditText etExperimentName = (EditText) findViewById(R.id.editTextExperimentName);
//first enable upload, then test experiment
if (rbUpload.isChecked()) {
Log.d(TAG, "global upload");
mApplication.setShouldUpload(true);
mApplication.setExperiment(false);
} else if (rbExperiment.isChecked()) {
Log.d(TAG, "experiment upload");
mApplication.setShouldUpload(true);
mApplication.setExperiment(true);
mApplication.setExperimentName(etExperimentName.getText().toString());
} else {
Log.d(TAG, "no upload");
mApplication.setShouldUpload(false);
mApplication.setExperiment(false);
}
Answers.getInstance().logCustom(new CustomEvent("Upload")
.putCustomAttribute("experiment", rbExperiment.isChecked() + "")
.putCustomAttribute("upload", rbUpload.isChecked() + ""));
//save to file
CheckBox cbSaveToFile = (CheckBox) findViewById(R.id.checkBoxSaveFile);
mApplication.setSaveToFile(cbSaveToFile.isChecked());
Answers.getInstance().logCustom(new CustomEvent("Save To File")
.putCustomAttribute("on", cbSaveToFile.isChecked() + ""));
//sound
SharedPreferences myPrefs = this.getSharedPreferences(SettingConstants.PREFERENCES, MODE_PRIVATE);
SharedPreferences.Editor prefsEditor = myPrefs.edit();
CheckBox soundCb = (CheckBox) findViewById(R.id.checkBoxNotificationSound);
prefsEditor.putBoolean(SettingConstants.SOUNDON, soundCb.isChecked());
Answers.getInstance().logCustom(new CustomEvent("Sound On")
.putCustomAttribute("on", soundCb.isChecked() + ""));
//zoom
CheckBox zoomCb = (CheckBox) findViewById(R.id.checkBoxZoom);
prefsEditor.putBoolean(SettingConstants.ZOOMBUTTONS, zoomCb.isChecked());
Answers.getInstance().logCustom(new CustomEvent("Zoom buttons")
.putCustomAttribute("on", zoomCb.isChecked() + ""));
prefsEditor.apply();
finish();
}