Help a newbie with Radio Buttons in XML

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Help a newbie with Radio Buttons in XML

Postby Sylee » Sun Dec 12, 2010 10:57 pm

I got into Android development a few days ago, when I bought myself a Galaxy S. Right now, I'm in the middle of creating a menu. A vertical menu with radio buttons. The text should appear on the left side and the radio buttons on the right side.

I've managed to get to this point, BUT! The radio buttons won't work as a group. They should be inside a RadioGroup, I know. And they are. I can get the buttons to work when I just line them up horizontally without any LinearLayouts inside the RadioGroup. But for my layout to work, I need to basically wrap the whole layout xml-file inside a RadioGroup. It's the only way I can get all the buttons inside the same one.

My layout outline looks something like this:

-RadioGroup
-------LinearLayout
-----------------LinearLayout
------------------------TextView
------------------------TextView
-----------------LinearLayout
------------------------RadioButton(id1)
-------LinearLayout
-----------------LinearLayout
------------------------TextView
------------------------TextView
-----------------LinearLayout
------------------------RadioButton(id2)



So do you have any suggestion that might help me solve this? I'd be forever thankful!
Sylee
Freshman
Freshman
 
Posts: 2
Joined: Sun Dec 12, 2010 10:44 pm

Top

Re: Help a newbie with Radio Buttons in XML

Postby blundell » Mon Dec 13, 2010 4:48 pm

Don't make a radiogroup, just add listener's to each radio button and manage them yourself.

i.e. If radio button 1 is pressed, 'unpress' all other radio buttons.

This is the functionality your hoping for right?
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: Help a newbie with Radio Buttons in XML

Postby Sylee » Mon Dec 13, 2010 7:24 pm

blundell wrote:Don't make a radiogroup, just add listener's to each radio button and manage them yourself.

i.e. If radio button 1 is pressed, 'unpress' all other radio buttons.

This is the functionality your hoping for right?


Ah, thanks. Didn't think about that. :)
Sylee
Freshman
Freshman
 
Posts: 2
Joined: Sun Dec 12, 2010 10:44 pm

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: Google [Bot] and 3 guests