Android disable radio group in xml

Linga picture Linga · Apr 10, 2013 · Viewed 9.2k times · Source

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

Answer

datalost picture datalost · Jul 16, 2013

Use the following attribute

android:clickable="false"