How to disable a RadioGroup until checkbox is checked

how to disable radio group in android
disable radio button android
what is a radio group
radiogroup isactivated
radiogroup clearcheck
appcompat radiogroup
radiogroup java
nested radio group android

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.

The real trick is to loop through all children view (in this case: CheckBox) and call it's setEnabled(boolean)

Something like this should do the trick:

//initialize the controls
final RadioGroup rg1 = (RadioGroup)findViewById(;
CheckBox ck1 = (CheckBox)findViewById(;

//set setOnCheckedChangeListener()
ck1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

    public void onCheckedChanged(CompoundButton checkBox, boolean checked) {
        //basically, since we will set enabled state to whatever state the checkbox is
        //therefore, we will only have to setEnabled(checked)
        for(int i = 0; i < rg1.getChildCount(); i++){

//set default to false
for(int i = 0; i < rg1.getChildCount(); i++){

how to disable the radio group until checkbox is selected, I tried all solutions provided at How to disable a RadioGroup until checkbox is checked Android: How do I enable/disable a Checkbox, depending on a Radio  When you click on checkbox .is(":checked") return true if it is checked other wise return false. According to selection of your checkbox button it will enable/disable button. Only one that worked for me in Chrome Run in mozilla firefox also.

You can use the onCheckedChangeListener on your CheckBox and use the method setEnabled on your RadioGroup.

Best wishes, Tim

how to disable the radio group until checkbox is selected, Enable and disable RadioGroup : RadioGroup « UI « Android. RadioGroup; public class Test extends Activity { @Override public void onCreate(Bundle icicle)​  As shown in the designer, no Radio Buttons are checked there. Below is just about all of the code for this simple form. Nothing calls for a Radio Buttons to be checked here or in the form's designer. Q: Is there a way to prevent any Radio Button from being checked when the form loads?

If you have just a few radio buttons, better way would be to setClickable(false) for all children


Enable and disable RadioGroup : RadioGroup « UI « Android, Selection control components allows users to complete tasks that require the selection of This will default the components color to white unless you've configured your application disabled. type. boolean. default. false. description. Disable the input Sets an indeterminate state for the checkbox I'm a radio button. input field disabled until radio button is checked (HTML) what to do if i need checkbox checked at the beginning and disable id To make checkbox checked at

RadioGroup cannot be disabled directly, we have to loop through the radio button and setEnabled as false.

// To disable the Radio Buttons of radio group.
    for (int i = 0; i < radioGroup.getChildCount(); i++) {

Selection control components, How to use JavaScript to select, deselect, or disable radio buttons in a group. Try checking and unchecking the "Hazardous Items" checkbox in the form to see r = radios[i]; // current radio button if ( hazard ) { // hazard checkbox checked if  How to use checked change listener on CheckBox in android application programmatically. In this tutorial we are implementing setOnCheckedChangeListener() method individually on radio button. So here is the complete step by step tutorial for Add setOnCheckedChangeListener on CheckBox in android. Code for file.

Take actions according to the state of the checkbox and set the radiogroup accordingly. Assuming that you have a radio-group named radiogroup you can enable or disable the radiogroup by


Add a OnCheckedChangeListener() to your checkbox.

Check/Uncheck/Disable Radio Buttons with JavaScript, We can read the user selected radio button value by using this in Jquery By click event of a button we can enable or disable the group of radio buttons. buttons by adding effects , user interactions and styles by using Checkboxradio UI. Learn how to enable & disable radio buttons in an HTML form by using jQuery. Just click on live demo or follow our codes. Here we have created an HTML form

Radio buttons control in JQuery to read checked value, disable , One idea would be to disable the radio buttons, and store their default value in a want to see the proper radio button selected based on what is stored in my database. If you have a hidden field followed by a checkbox or radio buttons with the fix the problem I was having before you replied, but it isn't working either… hey guys, so i want to disable the input button function unless checbox is checked. i found this forum and it sorta worked. the button is disabled when no checkbox is checked but it stays disabled even after checkbox is checked. this is the html:

Read-only Radio Buttons? - HTML & CSS, If someone checks the angry to accept checkbox then submit button will enable to click and if don't select the checkbox button will Easy conditional empty fields jQuery disable button. By Default Disable radio button If it has been checked, then it sets the disabled property on our submit button to FALSE. Essentially, this enables the button. However, if the user unchecks the checkbox, then our function will disable the button by setting the disabled property back to TRUE. Disabling a button until a checkbox is checked using JQuery.

How to disable a button in jQuery with Examples and Codes, 10.1 Disabling the Submit Button Until a Checkbox Is Checked Programming. How to get the values of checked checkboxes in JavaScript C# Use Check Box to Disable/Enable Button

  • It is nice to know that the "dirty hack" I did seems to be the actual way of doing it. :D
  • Sorry, but this does not work on RadioGroup. It does not propagate down it seems.
  • Individual RadioButton items have to be disabled.