views:

43

answers:

1

Hello, I'm trying to place a set of Checkboxes within the same RadioGroup in a tabular fashion.

Something like this:

  [Check1] [Check2]
  [Check3] [Check4]

I tried to have a couple of TableRow objects within the RadioGroup, but that removes the "group behaviour" and allows more than one Checkbox can be selected at the same time.

I am able to put all the items on a single line (by setting the RadioGroup's "orientation" to "horizontal") but not in a grid like style.

Any ideas?

Thanks.

A: 

I say you can try nested LinearLayouts. Outer 'RadioGroup' (think table) will have vertical orientation and each nested layout will have default horizontal. Something like this:

<?xml version="1.0" encoding="utf-8"?>
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RadioGroup01"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical">
<LinearLayout android:id="@+id/LinearLayout01" android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <RadioButton android:text="@+id/RadioButton01" android:id="@+id/RadioButton01" android:layout_width="wrap_content"
        android:layout_height="wrap_content"></RadioButton>
    <RadioButton android:text="@+id/RadioButton02" android:id="@+id/RadioButton02" android:layout_width="wrap_content"
        android:layout_height="wrap_content"></RadioButton>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout02" android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <RadioButton android:text="@+id/RadioButton03" android:id="@+id/RadioButton03" android:layout_width="wrap_content"
        android:layout_height="wrap_content"></RadioButton>
    <RadioButton android:text="@+id/RadioButton04" android:id="@+id/RadioButton04" android:layout_width="wrap_content"
        android:layout_height="wrap_content"></RadioButton>
</LinearLayout>

DroidIn.net