Answers for "set checked radio button through radio group in android"

3

how to get data from radio group in android

// get selected radio button from radioGroup
            int selectedId = radioGroup.getCheckedRadioButtonId();

            // find the radiobutton by returned id
            radioButton = (RadioButton) findViewById(selectedId);

            Toast.makeText(MyAndroidAppActivity.this,
                radioButton.getText(), Toast.LENGTH_SHORT).show();
Posted by: Guest on October-15-2020
1

how to set radio button checked in android programmatically

In your layout you can add android:checked="true" to CheckBox you want to be selected.

Or programmatically, you can use the setChecked method defined in the checkable interface:

RadioButton b = (RadioButton) findViewById(R.id.option1);
b.setChecked(true);
Posted by: Guest on March-19-2021

Code answers related to "set checked radio button through radio group in android"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language