开发者

Radio button in android

开发者 https://www.devze.com 2023-02-06 20:23 出处:网络
I have an array of radio button 开发者_JS百科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 uncheck

I have an array of radio button 开发者_JS百科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.

Radio button in android


Put all of those RadioButtons inside a RadioGroup


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


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" />

0

精彩评论

暂无评论...
验证码 换一张
取 消