user11018151
user11018151

Reputation:

How to unchecked radio button using radio group

how to multiple radio button unchecked using radio group please mention I know that this question is already exist on this site but code is not working app is crashed using this ( radiogroup.clear) please send correct code

Upvotes: 0

Views: 72

Answers (3)

try this

<RadioButton
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:text="@string/china_and_india"
  android:textSize="18sp"
  android:checked="false"
  android:layout_marginTop="2dp"
  android:background="@color/black"
  android:buttonTint="@android:color/holo_red_light"
  />

Upvotes: 0

ardiien
ardiien

Reputation: 804

Simple solution, selecting another RadioButton will clear the previous selection.

<RadioGroup
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:checkedButton="@+id/checkedInitialbtn"
     android:orientation="horizontal">

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="50dp"
        android:text="Option1" />

    <RadioButton
        android:id="@+id/checkedInitialbtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Option2" />
</RadioGroup>

Upvotes: 1

Prabh deep
Prabh deep

Reputation: 1042

use this code

Radiobutton radiobutton=null;

radiobutton=yourradiogroup.getcheckedid;
if(radiobutton.ischecked)
{
radiobutton.setchecked(false)
}

Upvotes: 1

Related Questions