Android的RadioButton和checkBox的用法-android学习之旅(十九)
来源:互联网 发布:剑倚天下进阶数据最新 编辑:程序博客网 时间:2024/05/21 21:48
RadioButton和checkBox简介
单选按钮(RadioButton)和复选框(CheckBox)都继承了Button,因此属性的设置和Button差不多,只是加了一个android:chencked属性。
用来设置是否被选中。
RadioButton和checkBox的区别
前者如果一组只能只能选中一个,一次通常会与RadioGroup一块使用,后者没有限制。
实例
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity" android:orientation="vertical"> <TableRow android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="性别:" android:textSize="16px"/> <RadioGroup android:orientation="horizontal" android:id="@+id/rg" android:layout_gravity="center_horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="男" android:checked="true"/> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="女" /> </RadioGroup> </TableRow> <TableRow android:layout_height="wrap_content" android:layout_width="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="喜欢的颜色" android:textSize="16px"/> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="红色"/> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="蓝色"/> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="绿色"/> </TableRow> <TableRow android:layout_height="match_parent" android:layout_width="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="show"/> </TableRow></LinearLayout>
效果图
0 0
- Android的RadioButton和checkBox的用法-android学习之旅(十九)
- Android UI学习笔记 之RadioButton和CheckBox的使用
- android中的RadioButton和CheckBox的简单用法
- Android(SDK 1.5) RadioButton 和 CheckBox 的用法
- android中checkbox和radiobutton的使用
- android radiobutton和checkbox的使用
- Android中RadioButton和Checkbox的使用
- android开发的CheckBox和RadioButton
- android学习十九(WebView的用法)
- Android CheckBox和RadioButton
- Android学习路之RadioButton&Checkbox
- 【幻化万千戏红尘】qianfeng-Android-Day03-RadioButton及RadioGroup的用法、CheckBox、ProgressBar基础学习:
- android学习笔记12:RadioButton和checkbox
- Android开发之RadioButton和CheckBox
- Android控件之Checkbox和RadioButton
- 【Android学习笔记】RadioGroup,RadioButton的使用&CheckBox的使用
- Android学习笔记(三)checkbox和radiobutton
- Android checkbox和radiobutton 以及Toast和AlertDialog的使用
- hdu 1011 Starship Troopers
- Servlet生命周期
- gsoap 注意事项
- Hadoop深入研究(HDFS)---HDFS介绍
- Android应用内语言切换实现
- Android的RadioButton和checkBox的用法-android学习之旅(十九)
- 封装分页类
- poj1436 Horizontally Visible Segments
- uva 10106 Product(高精度大数乘法)
- maven基本使用
- Linux下使用Supervise
- Gh0st源码学习(三)生成DLL和DAT文件
- 使用javaswing设定背景图片为窗体大小(原创)
- php 5.4.38