Questions tagged [android-radiobutton]

Use for the android.widget.RadioButton element. Radio buttons are normally used together in a RadioGroup.

Radio buttons allow the user to select one option from a set. You should use radio buttons for optional sets that are mutually exclusive if you think that the user needs to see all available options side-by-side.

Radio buttons are normally used together in a RadioGroup. When several radio buttons live inside a radio group, checking one radio button unchecks all the others.

Useful links

347 questions
216
votes
27 answers

Change the circle color of radio button

I want to change the color of the circle of RadioButton in one of my projects, but I could not understand which property to set. The background color is black, so it gets invisible. I want to set the color of the circle to white.
Amandeep Singh
  • 3,754
  • 8
  • 51
  • 72
107
votes
7 answers

Set selected index of an Android RadioGroup

Is there a way to set the selected index of a RadioGroup in android, other than looping through the child radiobuttons and selecting checking the radio button at the selected index? Note: I am populating the Radio Button Group at run time.
Hassan Mokdad
  • 5,832
  • 18
  • 55
  • 90
87
votes
20 answers

how to put the text on the left of a radio button in android

I want to put the text of a radio button on the left not on the right I found this solution
BasILyoS
  • 995
  • 1
  • 10
  • 15
63
votes
6 answers

Android: RadioGroup - How to configure the event listener

From my understanding, to determine if a checkbox is "clicked" and find if it's checked or not, code such as the following can be used: cb=(CheckBox)findViewById(R.id.chkBox1); cb.setOnCheckedChangeListener(this); public void…
Ryan
  • 9,821
  • 22
  • 66
  • 101
46
votes
3 answers

Uncheck all RadioButton in a RadioButtonGroup

What I wanted to achieve is this: Right after the activity starts, I want that no RadioButton is selected/checked. My problem is this: When the activity starts, the first RadioButton is always selected/checked. I tried…
Jayson Tamayo
  • 2,741
  • 3
  • 49
  • 76
35
votes
6 answers

Creating RadioGroup programmatically

I'm getting an Error while working with the following code Error: The specified child already has a parent you must call removeView on the child's parent first Anyone please help me in resolving this Error: RadioButton[] radiobutton = new…
32
votes
8 answers

How to set only one RadioButton Can be selected at the time in RadioGroup

I've created a radio button in radiogroup, but when I try running the apps all radio button can be selected all the time, and how to set only one radiobutton can be selected at one time? I'm using Fragment RadioGroup radioGroup = (RadioGroup)…
F_X
  • 491
  • 2
  • 7
  • 16
20
votes
2 answers

Android - Set padding to RadioButton pin

I'have tried lot of combination both with xml and programmatically but nothing to do yet. This is the scenario (pay attention to the small red arrow): I have some RadioButtons inside a radio group, in xml this scenario could be represented…
madx
  • 6,723
  • 4
  • 55
  • 59
14
votes
6 answers

Radio Button is only partially checked

I know this sound weird so here is the picture. It hold the correct value. The correct radiobutton is (partially) selected. All logic in the OnCheckedChangeListener is executed correctly. I'm completly stunned. Why is the radio button not fully…
Robin Dijkhof
  • 18,665
  • 11
  • 65
  • 116
12
votes
2 answers

How to provide spacing between android Radio Buttons of Vertical orientation

I got a scenario where I need to provide spacing between radio buttons arranged vertically. The below is my Layout:
12
votes
9 answers

Set default checked Radio Button

I'm creating a RadioGroup with RadioButtons dynamically and need to have one radio button checked by default. I've done this by using both radioButton.setChecked(true) and radioButton.toggle(); The problem I have is that when I at runtime select…
thehindutimes
  • 321
  • 1
  • 6
  • 19
11
votes
2 answers

How to set an image's width and height when it's set in drawableLeft

I set an image to a RadioButton's drawableLeft, but it's to big. I want to set the image's height, width and scaleType in order to let it looks ok, just like in an…
L. Swifter
  • 3,179
  • 28
  • 52
9
votes
4 answers

Radio Button style programmatically

I would to create a number of radio button dinamically in a fragment, I only have problem with style. If I put radiobutton code in the xml file, default style is applied correctly, but when I create radiobutton through a function I see different…
Cristian
  • 329
  • 2
  • 6
  • 14
7
votes
3 answers

RadioButton is leaving black checked circle after unchecking

My RadioButtons in my RadioGroup are leaving a black checked circle after I uncheck them or click on another RadioButton in the group. How do I prevent this from happening?
DIRTY DAVE
  • 2,523
  • 2
  • 20
  • 83
5
votes
1 answer

How to speed up or turn off animation of RadioButton on Android?

I have a RadioGroup with dynamically added RadioButtons. In my Activity, I close the activity immediately after a RadioButton is selected. However, this leads to an artifact where two RadioButtons look like they are selected before the Activity…
VIN
  • 6,385
  • 7
  • 38
  • 77
1
2 3
23 24