Sudipta Som
Sudipta Som

Reputation: 6577

Radio button in android

I have an array of radio button from where i am creating radio buttons dynamically in my layout. Here what i want, when i check one radio button then other radio buttons should be unchecked. How to manipulate this using radio button array? Please some body help!

Here is the image. Radio Buttons does not unchecked automatically.

enter image description here

Upvotes: 0

Views: 1135

Answers (3)

Pa1
Pa1

Reputation: 192

Yes, RadioButtons does this automatically. Here is the code for your reference. Hope it helps you.

  <RadioButton android:id="@+id/radio_red"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Red" />

  <RadioButton android:id="@+id/radio_blue"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Blue" />

Upvotes: 0

Aman Aalam
Aman Aalam

Reputation: 11251

Put all of those RadioButtons inside a RadioGroup

Upvotes: 2

AitorTheRed
AitorTheRed

Reputation: 553

RadioButtons does this automatycally but you have to group them in a RadioGroup: http://developer.android.com/intl/es/reference/android/widget/RadioGroup.html

Upvotes: 2

Related Questions