Android Bug: Radio Groups/Buttons

This was informally confirmed by someone at Google:

Given this layout code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  id="@+id/ll">
</LinearLayout>

And this Java code:

public void onCreate(Bundle icicle)
{
    super.onCreate(icicle);
    setContentView(R.layout.main);

    LinearLayout ll = (LinearLayout)findViewById(R.id.ll);

    RadioGroup rg = new RadioGroup(this);
    rg.setLayoutParams(new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));

    ll.addView(rg);

    RadioGroup.LayoutParams rlp = new RadioGroup.LayoutParams(
        RadioGroup.LayoutParams.WRAP_CONTENT,
        RadioGroup.LayoutParams.WRAP_CONTENT);

    RadioButton foo = new RadioButton(this);
    foo.setText("foo");
    foo.setLayoutParams(rlp);
    rg.addView(foo);

    RadioButton bar = new RadioButton(this);
    bar.setText("bar");
    bar.setLayoutParams(rlp);
    rg.addView(bar);

    RadioButton baz = new RadioButton(this);
    baz.setText("baz");
    baz.setLayoutParams(rlp);
    rg.addView(baz);
}

The resulting radio buttons fail to be mutually exclusive. This is a bit frustrating, as Hecl doesn’t utilize the XML layout system. Or rather, you can use that if you want, or you can create everything in Hecl.

All radiobuttons selected

The individual at Google says the problem will be fixed in a future SDK release, so hopefully things will work in the near future. I also hope it’s open sourced soonish, so that problems like this can be fixed without requiring the intervention of “the hand of Google”. Of course, in this market, there’s also the issue of things being shipped on hardware, where open source or not doesn’t matter much if the bug is out there, because you simply can’t fix it on millions of devices. Hopefully the product that ships will be very solid.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s