Questions tagged [radio-group]

radio-group is used to create a multiple-exclusion scope for a set of radio buttons. Checking one radio button that belongs to a radio group unchecks any previously checked radio button within the same group.

1047 questions
236
votes
19 answers

How to get the selected index of a RadioGroup in Android

Is there an easy way to get the selected index of a RadioGroup in Android or do I have to use OnCheckedChangeListener to listen for changes and have something that holds the last index selected? example xml:
John Boker
  • 82,559
  • 17
  • 97
  • 130
175
votes
5 answers

Multiple radio button groups in one form

Is it possible to have multiple radio button groups in a single form? Usually selecting one button deselects the previous, I just need to have one of a group deselected.
AlexG
  • 5,649
  • 6
  • 26
  • 43
148
votes
8 answers

How to set radio button checked as default in radiogroup?

I have created RadioGroup and RadioButton dynamically as following: RadioGroup radioGroup = new RadioGroup(context); RadioButton radioBtn1 = new RadioButton(context); RadioButton radioBtn2 = new…
Sandeep Kumar P K
  • 7,412
  • 6
  • 36
  • 40
131
votes
9 answers

How to set OnClickListener on a RadioButton in Android?

I have two RadioButtons inside a RadioGroup. I want to set OnClickListener on those RadioButtons. Depending on which RadioButton is clicked, I want to change the text of an EditText. How can I achieve this?
mayur rahatekar
  • 4,410
  • 12
  • 37
  • 51
103
votes
21 answers

How to group RadioButton from different LinearLayouts?

I was wondering if is possible to group each single RadioButton in a unique RadioGroup maintaining the same structure. My structure look like…
marcoqf73
  • 1,306
  • 3
  • 14
  • 18
86
votes
11 answers

How to check if a radiobutton is checked in a radiogroup in Android?

I need to set validation that user must fill / select all details in a page. If any fields are empty wanna show Toast message to fill. Now I need set validation for RadioButton in the RadioGroup. I tried this code but didn't work properly. Suggest…
Srihari
  • 2,387
  • 9
  • 51
  • 82
72
votes
12 answers

RadioGroup: How to check programmatically

I create a RadioGroup from XML
Bao Le
  • 16,643
  • 9
  • 65
  • 68
67
votes
6 answers

AngularJs: How to set radio button checked based on model

I have a model returning in the storeLocations object with a isDefault value. if isDefault returns true, I wan't to set that radio button in the group as checked. Not sure if I need to do a $each(data, function(index,value) and iterate through each…
Christopher Marshall
  • 10,678
  • 10
  • 55
  • 94
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
41
votes
8 answers

How to disable a RadioGroup until checkbox is checked

I have a radio group which I do not want to user to be able to select any of the buttons until a particular checkbox is selected within my app. If the checkbox is unticked then this disables the radio-group. How do I go about doing this.
W0lf7
  • 729
  • 1
  • 8
  • 15
37
votes
8 answers

Set mat-radio-button default selected in a mat-radio-group with angular2

I got this problem in my angular app. I have many options in a mat-radio-group but these are dynamically placed according to a json object. Something like this: This is the json object { "list": [ {"name": "some name 1", ID: "D1"}, …
Sergio Mendez
  • 1,311
  • 8
  • 33
  • 56
37
votes
5 answers

Multiple radio button groups in MVC 4 Razor

I need to have multiple radio button groups in my form like this: I know it's simply done by specifying the same "name" html attribute for each group. HOWEVER MVC doesn't let you specify your own name attribute when using html helper like…
Ali
  • 1,152
  • 2
  • 14
  • 33
34
votes
4 answers

binding radiobuttons group to a property in WPF

Let's imagine that I have: And then in my data source class I have: public bool…
Bogdan Verbenets
  • 25,686
  • 13
  • 66
  • 119
33
votes
3 answers

Get the array of RadioButtons in a RadioGroup in Android

Is there any way of getting an array (or a collection) of the RadioButtons in an Android RadioGroup? I would like to add individual listeners to radio buttons but I don't see any obvious way of iterating over them.
Tim
  • 5,767
  • 9
  • 45
  • 60
32
votes
6 answers

android onCheckedChanged for radiogroup

I'm writing an Activity in android where I have two radio buttons under a RadioGroup. One of them is checked by default. But I can't trigger the event in onCreate method so that I can do something in that. The onCheckedChanged is running fine when…
user2534310
  • 459
  • 1
  • 5
  • 10
1
2 3
69 70