Scooter
Scooter

Reputation: 86

How can I place an EditText and TextView in a RadioButton?

I have a RadioGroup inside of a RelativeLayout. I've got a few RadioButtons for different options, like "Bob", "Joe", and "Fred". However, I need to add an "Other..." option with an EditText right next to a RadioButton in case a user wants to enter "Steve". Is there a way to do this?

Upvotes: 0

Views: 1681

Answers (1)

Shomari
Shomari

Reputation: 414

Just one idea that comes to mind is to use android:layout_marginLeft and android:layout_marginTop tags to position the EditText field where you need it to be. Be sure to use dip to support multiple densities across devices.

<EditText
    android:layout_marginLeft="65dip"
    android:layout_marginTop="100dip"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:text="" />

Then, if the user selects your Other radio button, just grab the value from EditText.

Upvotes: 1

Related Questions