//项目源码附上,可以下载共享!
<!--
单选按钮操作测试:
1、单选按钮:RadioButton 需要配合 RadioGroup 进行使用,RadioGroup 是 RadioGroup 的承载体
2、每一组RadioGroup 里面只能有一个RadioButton 被选中,不同的组之间互不影响;
3、一个RadioGroup 里面至少包含两个RadioButton , 能包含多个单选按钮;
4、每一组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:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="单选按钮测试" />
<!-- 单选按钮的组 , 里面包含的是三个单选按钮 , 进行选择的测试 -->
<RadioGroup
android:id="@+id/group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/radioRed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="红色" />
<RadioButton
android:id="@+id/radioGreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="绿色" />
<RadioButton
android:id="@+id/radioBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="黑色" />
</RadioGroup>
<!-- 复选框的测试 -->
<!--
一组: CheckBox 能同时的选择多个,每次点击的时候可以选择是否被选中,在UI 中默认的是以矩形的方式显示;
事件:CompoundButton.OnCheckedChangeListener 后部分与按钮 状态控件的事件名称一致,加以不同的前缀进行区别
-->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="请选择您的爱好"
android:textStyle="normal" />
<CheckBox
android:id="@+id/cb1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="游泳" />
<CheckBox
android:id="@+id/cb2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="散步" />
<CheckBox
android:id="@+id/cb3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="看书" />
<CheckBox
android:id="@+id/cb4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="篮球" />
<!-- 状态开关测试 -->
<!--
控件名称:ToggeButton
属性:设置开/关的时候对应的文本的值:textOn/textOff
-->
<!-- 开关转换器 默认是开 纵向 -->
<ToggleButton
android:id="@+id/toggle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:checked="true"
android:textOff="横向排列"
android:textOn="纵向排列" />
<!-- 使用线性布局结合状态栏的排列 -->
<LinearLayout
android:id="@+id/linears"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="clock1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="clock2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="clock3" />
</LinearLayout>
</LinearLayout>
<!--
时钟测试
AnalogClock 模拟时钟
DigitalClock 数字时钟
-->
<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:background="@drawable/a"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="时钟测试" />
<AnalogClock
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<!-- 数字时钟 -->
<!--
时钟(AnalogClock和DigitalClock)的功能和用法:
AnalogClock继承了View组件,重写了View的OnDraw方法,它会在View上显示模拟时钟。
DigitalClock本身就继承了TextView,也就是说它本身就是文本框,只是它里面显示的内容是当前时间。
AnalogClock和DigitalClock都会显示当前时间,不同的是;
DigitalClock显示数字时钟,可以显示当前的秒数;
AnalogClock显示模拟时钟,不会显示当前秒数;
-->
<DigitalClock
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
分享到:
相关推荐
autocompletetextview自动完成文本框 spinner switch状态切换 ToggleButton功能切换 单选按钮(RadioButton)和复选框(CheckBox) 时钟(AnalogClock和DigitalClock)的功能和功法
把其他类型的控件放在其他选项框中)、复选控件(用来制作复选按钮)、单选控件(制作单选按钮)、组合框控件(用来制作功能更为强大的列表框,既有文本框控件的功能,还有列表框控件的功能)、列表框控件(制作各种...
复选框控件 40 列表框控件 44 图片控件 48 更多的功能 49 完整的示例代码 50 第四章:Windows图形编程 60 创建菜单 61 创建工具条 67 绘制图形 74 第五章:数据库编程 79 数据库简介 79 数据库的建立 80 ODBC数据源...
实例29 单选框和复选框 实例30 列表框和组合框 实例31 列表视图 实例32 树视图 实例33 Timer控件 实例34 Splitter控件 实例35 时钟控件和日历控件 实例36 MDI窗口 实例37 窗体继承 ...
2.3.5 状态开关按钮(ToggleButton) 的功能与用法 71 2.3.6 时钟(AnalogClock和Digital Clock)的功能与功法 73 2.3.7 图像视图(ImageView)的 功能和用法 75 2.4 高级界面组件 79 2.4.1 自动...
实例29 单选框和复选框 实例30 列表框和组合框 实例31 列表视图 实例32 树视图 实例33 Timer控件 实例34 Splitter控件 实例35 时钟控件和日历控件 实例36 MDI窗口 实例37 窗体继承 ...
第10章 单选框和复选框 10.1 选择了哪一个单选框 10.2 单击文字实现单选框的选定 10.3 被选中的复选框求和 10.4 复选框组选 10.5 复选框分组全选 10.6 复选框和文本框的联动效果 10.7 单击任意单元格都能自动选中复...
第10章 单选框和复选框 10.1 选择了哪一个单选框 10.2 单击文字实现单选框的选定 10.3 被选中的复选框求和 10.4 复选框组选 10.5 复选框分组全选 10.6 复选框和文本框的联动效果 10.7 单击任意单元格都能自动选中复...
实例011: 在屏幕中显示复选框 18 实例012: 在屏幕中显示单选框 21 实例013: 在屏幕中显示下拉列表框 22 实例014: 在屏幕中实现自动输入文本 效果 26 实例015: 使用日期选择器控件DatePicker 28 实例016: 自动...
一,示例实现的功能要求 1, 文本视图。 2, 图像视图。 3, 复选按钮。 4, 单选按钮。 5, 按钮。 6, 编辑框。 7, 切换按钮。 8, 指针时钟和数字时钟。
3.7 复选框的全选,多选,全不选,反选 3.8 文件上传过程中判断文件类型 4、字符类 4.1 判断字符全部由a-Z或者是A-Z的字字母组成 4.2 判断字符由字母和数字组成。 4.3 判断字符由字母和数字,下划线,点号组成....
3.6 判断复选框是否选择. 3.7 复选框的全选,多选,全不选,反选 3.8 文件上传过程中判断文件类型 4、字符类 4.1 判断字符全部由a-Z或者是A-Z的字字母组成 4.2 判断字符由字母和数字组成。 4.3 判断字符...
vb复习资料目录 1.对象的有关概念 2.基本控件和窗体 3.工程的管理及环境的设置 4.常见错误 5. 数据类型 ...13.单选按钮和复选框 14.框架 15.时钟 16.图形控件 17.鼠标与键盘事件过程 18.数组 19.过程