Hello,

I have a bunch of radiobuttons in a radiogroup and I would like for
them to be arranged in two columns. The reason being so that they fit
on the screen and so that I can change the columns to be four in
landscape mode. I thought to intermingle the tablelayout with the
radiogroup. with the following code:

<TableLayout android:id="@+id/TableLayout01"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
  <RadioGroup android:layout_height="wrap_content" android:id="@+id/
radiogroupChoices" android:layout_width="fill_parent">
    <TableRow android:id="@+id/TableRow01"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
      <RadioButton android:layout_height="wrap_content"
android:text="One" android:id="@+id/RadioButtonOne"
android:layout_weight="1" android:layout_width="fill_parent"></
RadioButton>
      <RadioButton android:layout_height="wrap_content"
android:text="Two" android:id="@+id/RadioButtonTwo"
android:layout_width="fill_parent" android:layout_weight="1"></
RadioButton>
    </TableRow>
    <TableRow android:id="@+id/TableRow02"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
      <RadioButton android:layout_height="wrap_content"
android:text="Three" android:id="@+id/RadioButtonThree"
android:layout_weight="1" android:layout_width="fill_parent"></
RadioButton>
      <RadioButton android:layout_height="wrap_content"
android:text="Four" android:id="@+id/RadioButtonFour"
android:layout_weight="1" android:layout_width="fill_parent"></
RadioButton>
    </TableRow>
  </RadioGroup>
</TableLayout>

In this setup, the radio buttons show up in neat columns but the
problem is the instant that I do that it takes them out of the
radiogroup.

I tried leaving them in the TableLayout and just changing the parent
of the radiobuttons by using radiogroup.addView(eachbutton) but that
wouldn't work since they were already defined in the xml.

I also tried just having a regular radiogroup with the radiobuttons in
them and then just changing the orientation to horizontal, so that I
could set the width programatically based on the screen width

<ScrollView android:layout_width="fill_parent" android:id="@+id/
scrollviewListHolder" android:layout_height="fill_parent"
android:layout_weight="1">
  <RadioGroup android:id="@+id/radiogroupChoices"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_weight="1" android:orientation="horizontal">
    <RadioButton android:layout_height="wrap_content"
android:text="One" android:id="@+id/RadioButtonOne"
android:layout_width="wrap_content"></RadioButton>
    <RadioButton android:layout_height="wrap_content"
android:text="Two" android:id="@+id/RadioButtonTwo"
android:layout_width="wrap_content"></RadioButton>
  </RadioGroup>
</ScrollView>

but that wouldn't work either. as many as would fit into one row would
fit and the rest would be off the screen.

Is there a way to arrange them in such a fashion while still keeping
them in the radiogroup?

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en

Reply via email to