【发布时间】:2016-09-13 15:23:59
【问题描述】:
所以我在这里有一个问题。我想实现一个有三个单选按钮的活动
rb1
rb2
rb3
还有一个按钮提交。 When any one of those are selected and the button is clicked, it should send an int value to the next activity.例如,如果选择了 rb2 并且我点击了按钮提交,它应该发送 int 值 10。但是如果选择了 rb3 并且onClick,它应该发送 14 到下一个 Activity。
该怎么做呢?这是我当前的代码
public void onRadioButtonClicked(View view) {
// Is the button now checked?
boolean checked = ((RadioButton) view).isChecked();
// Check which radio button was clicked
switch(view.getId()) {
case R.id.radio_btn1:
if (checked)
// Send value 10 to the next activity
break;
case R.id.radio_btn2:
if (checked)
// Send value 14 to the next activity
break;
}
}
【问题讨论】:
-
你知道
Intents吗? -
是的,我知道意图
标签: java android radio-button radiobuttonlist radio-group