【发布时间】:2010-07-22 08:30:35
【问题描述】:
我在 Android 中有一个单选按钮组,看起来像:
选择颜色:
- 红色
- 蓝色
- 橙色
- 绿色
我需要选择单选按钮及其值。
我在 radiogroup rg 中有 4 个单选按钮
rb1a=(RadioButton)findViewById(R.id.rb1a);
rb1b=(RadioButton)findViewById(R.id.rb1b);
rb1c=(RadioButton)findViewById(R.id.rb1c);
rb1d=(RadioButton)findViewById(R.id.rb1d);
tv1=(TextView)findViewById(R.id.tv1);
next1=(Button)findViewById(R.id.next1);
rg=(RadioGroup)findViewById(R.id.rg);
// I have error after this line.please help
rg.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(RadioGroup group, int checkedId)
{
}
@Override
public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
// TODO Auto-generated method stub
}
});
【问题讨论】:
-
您的单选按钮或 UI 是如何定义的?
-
Sanjeev,别忘了选择一个答案,以便我们关闭这个问题
标签: android radio-button