Android 组单选按钮
我有3个单选按钮在组中,我想调用单选按钮的点击意图,但当我点击单选按钮时,我得到了异常,我无法找出我得到了什么样的异常 这是我的密码Android 组单选按钮,android,radio-group,Android,Radio Group,我有3个单选按钮在组中,我想调用单选按钮的点击意图,但当我点击单选按钮时,我得到了异常,我无法找出我得到了什么样的异常 这是我的密码 public class Contentstory extends Activity { RadioButton Child,Adult,Animated ; RadioGroup radiogroup1; @Override public void onCreate(Bundle savedInstanceState) {
public class Contentstory extends Activity {
RadioButton Child,Adult,Animated ;
RadioGroup radiogroup1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content);
radiogroup1 = (RadioGroup) findViewById(R.id.radioGroup1);
final RadioButton Child = (RadioButton)findViewById(R.id.radio0);
radiogroup1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (Child.isChecked()){
Intent intent = new Intent(getApplicationContext(),StoryList.class);
Contentstory.this.startActivity(intent);
}
}
});
RadioGroup 1=(RadioGroup)findviewbyd(R.id.RadioGroup 1)代码>
你能解释一下,你是如何知道自己遇到了异常,却看不到异常是什么吗?也许用截图?这是在模拟器上还是在设备上发生的?如果它解决了您的问题,那么接受它作为答案谢谢Sathya的回复,因为您说我的代码不包含任何错误,我同意您的看法。事实上,我的问题存在于XML文件中,异常显示在以下行“Intent Intent=new Intent(getApplicationContext(),StoryList.class);”中,但再次感谢您的回答,Sathya没有给出答案,他只是编辑了它,如果它能帮助您解决问题,请接受它作为答案并投票表决