Andriod游戏开发系统控件-RadioButton


Andriod游戏开发系统控件-RadioButton

RadioButton是单选按钮,和CheckButton一样都基础Button。RadioButton一般都存在单选组(RadioGroup)中,当多个RadioButton存放在一个单选组中,只能选一个RadioButton;如果想实现RadioButton的多选,那就需要多个RadioGroup。

创建项目:RadioButtonProject

功能:实现单选按钮

项目运行效果图:

修改布局文件:

=>>main.xml

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"   
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     >  
  7.     <RadioGroup  
  8.     android:id="@+id/radGrp"  
  9.     android:layout_width="wrap_content"  
  10.     android:layout_height="wrap_content"  
  11.     >  
  12.     <RadioButton  
  13.         android:id="@+id/rb1"  
  14.         android:layout_width="fill_parent"  
  15.         android:layout_height="wrap_content"  
  16.         android:text="@string/radB1"  
  17.         />  
  18.     <RadioButton  
  19.         android:id="@+id/rb2"  
  20.         android:layout_width="fill_parent"  
  21.         android:layout_height="wrap_content"  
  22.         android:text="@string/radB2"  
  23.         />  
  24.     <RadioButton  
  25.         android:id="@+id/rb3"  
  26.         android:layout_width="fill_parent"  
  27.         android:layout_height="wrap_content"  
  28.         android:text="@string/radB3"  
  29.         />  
  30.     </RadioGroup>  
  31.     </LinearLayout>  
  • 1
  • 2
  • 下一页

相关内容