歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Andriod游戲開發系統控件-RadioButton

Andriod游戲開發系統控件-RadioButton

日期:2017/3/1 10:22:57   编辑:Linux編程

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>
Copyright © Linux教程網 All Rights Reserved