In my android application, I need to disable radio group in xml layout. I searched, but I found only through pro-grammatically not in xml layout.
My code is here
<RadioGroup
android:id="@+id/menu1"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_x="170dp"
android:layout_y="100dp" >
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yes" />
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No" />
</RadioGroup>
I've tried with android:enabled="false" but it is not supported by Radio Group. But it works in RadioButton as
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:text="Yes" />
Now my question is If my RadioGroup contains 10 RadioButtons, I want to set enable=false only for the RadioGroup, not for every individual RadioButton. So how can I disable the entire RadioGroup instead of disabling RadioButtons?
I need only in xml layout. Thanks in advance
Use the following attribute
android:clickable="false"
You are absolutely right there is no property given for radio group for disable it.
you can not find any method to do like in this developer site LINK
Now my question is If my RadioGroup contains 10 RadioButtons, I want to set enable=false only for the RadioGroup, not for every individual RadioButton. So how can I disable the entire RadioGroup instead of disabling RadioButtons?
All you can do to disable it is in java code of activity .
for (int i = 0; i <group.getChildCount(); i++)
{
group.getChildAt(i).setEnabled(false);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With