简体   繁体   中英

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM