I know I"m too late to reply to this, but for anyone who comes through here
looking for a solution...
You must register an id for each RadioButton in the RadioGroup. The
RadioGroup will clear RadioButton selection based on their resource id.
RadioGroup group = new RadioGroup(this.
getApplicationContext());
this.setContentView(group);
for (int i = 0; i < 10; i++) {
group.addView(getRadioButton(i));
}
private RadioButton getRadioButton(final int position) {
RadioButton v = new RadioButton(this.getApplicationContext());
*int i = 0;*
if (position == 0) {
v.setChecked(true);
*v.setId(i++);*
}
return v;
}
On Wednesday, September 15, 2010 9:10:44 AM UTC-4, Christophe wrote:
>
> hello,
>
> I have a simple RadioGroup in one of my view, with several
> RadioButton :
>
> RadioGroup group = new RadioGroup(this.getApplicationContext());
> this.setContentView(group);
>
> for (int i = 0; i < 10; i++) {
> group.addView(getRadioButton(i));
> }
>
>
> private RadioButton getRadioButton(final int position) {
> RadioButton v = new RadioButton(this.getApplicationContext());
> if (position == 0) {
> v.setChecked(true);
> }
>
> return v;
> }
>
>
> It display 10 radio buttons, and one of them is checked (the first
> one). But if I click on another radio button, the first one stay
> selected ...
>
> Is there something wrong with my code ?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en