I have a custom DialogPreference
subclass in which I would like to have a RadioGroup
with three radio buttons. The first two are vanilla RadioButton
components with titles, but for the third I would like to place an EditText
directly to the right of it so I can enter a custom value when that button is selected.
I have tried putting the third button into a horizontal LinearLayout
along with the EditText
but then the third button does not participate in the parent RadioGroup
anymore.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RadioGroup
android:id="@+id/lactate_radio"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/lactate_default_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lactate_default_value"/>
<RadioButton
android:id="@+id/lactate_calibrated_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lactate_calibrated_value" />
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/lactate_custom_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lactate_custom_value"/>
<EditText
android:id="@+id/lactate_custom_value_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</RadioGroup>
</LinearLayout>
I have also tried adding this LinearLayout
programmatically but still had the same behavior. Is there any way to do this, perhaps by explicitly telling the parent RadioGroup
about the third button or by somehow positioning the EditText
appropriately without using a horizontal LinearLayout
? Otherwise, I think I'll have to write a RadioButton
subclass which ought to be a real party!