views:

35

answers:

1

I want to create a simple layout like the following:

(o) Radio button A
(o) Radio button B [textedit]
    [x] checkbox

For that I've created the following layout.xml:

<RadioGroup 
    android:layout_above="@+id/RadioButton_Count" 
    android:id="@+id/RadioGroup01" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent">
    <RadioButton 
        android:layout_height="wrap_content" 
        android:id="@+id/RadioButton_A" 
        android:text="Play forever" 
        android:checked="true" 
        android:layout_width="fill_parent" 
        android:textSize="20sp">
    </RadioButton>
    <RelativeLayout 
        android:id="@+id/RelativeLayout01" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content">
        <RadioButton 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:id="@+id/RadioButton_B" 
            android:text="Count:" 
            android:textSize="20sp">
        </RadioButton>
        <EditText 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:id="@+id/EditText_NumCount" 
            android:inputType="number" 
            android:layout_toRightOf="@+id/RadioButton_B" 
            android:width="70sp" >
        </EditText>
        <CheckBox 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:id="@+id/CheckBox_StopCount" 
            android:text="Stop" 
            android:layout_below="@+id/RadioButton_B" 
            android:textSize="18sp">
        </CheckBox>
    </RelativeLayout>
</RadioGroup>

It looks right, but the problem is that the radiobuttons doesn't connect between each other, i mean that they can be both on in the same moment. I think it's because even if they're hanging from the same the second one is inside another layout :\ Does anyone have some idea how could I make this kind of layout (Mainly the [textedit] just right the RadioButton B), getting working also the radiobuttons? Thank you very much

A: 

The first thing to try is to close your RadioGroup right after you close the last RadioButton instead of at the end. A better solution is to use a RelativeLayout as the overall container. Next add your RadioGroup and both buttons and close the group. Add the other elements relative to the rest of the layout.

Phobos