Android的RadioButton和checkBox的用法-android学习之旅(十九)
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>
效果图
Android的RadioButton和checkBox的用法-android学习之旅(十九)的更多相关文章
- Android的搜索框SearchView的用法-android学习之旅(三十九)
SearchView简介 SearchView是搜索框组件,他可以让用户搜索文字,然后显示.' 代码示例 这个示例加了衣蛾ListView用于为SearchView增加自动补全的功能. package ...
- 【转】 Pro Android学习笔记(十九):用户界面和控制(7):ListView
目录(?)[-] 点击List的item触发 添加其他控件以及获取item数据 ListView控件以垂直布局方式显示子view.系统的android.app.ListActivity已经实现了一个只 ...
- Android学习路线(十九)支持不同设备——支持不同(Android)平台版本号
当最新的Android版本号为你的应用提供着非常棒的APIs时.你却要在很多其它的设备更新之前继续支持老的系统版本号.这篇课程怎样在继续支持低版本号的系统的情况下使用新版本号的高级API. Platf ...
- Android学习笔记(十九)——内容提供器
//此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 内容提供器(Content Provider)主要用于在不同的应用程序之间实现数据共享的功能,它提供了一套完整 ...
- android 学习随笔二十九(自定义监听 )
package com.itheima.momo.dialog; import com.itheima.momo.R; import android.app.AlertDialog; import a ...
- Android的ViewAnimator而它的子类ViewSwitcher-android学习之旅(三十三)
ViewAnimator遗传FrameLayout,重合使用多个组件.可以增加部件数量,然后会有时间切换动画. ViewAnimator及其子类的继承关系 ViewAnimator经常使用属性 Vie ...
- 从零開始学android<mediaplayer自带播放器(视频播放).四十九.>
MediaPlayer除了能够对音频播放之外,也能够对视频进行播放,可是假设要播放视频仅仅依靠MediaPlayer还是不够的.还须要编写一个能够用于视频显示的空间,而这块显示空间要求能够高速的进行G ...
- Android数据库Sqlite-android学习之旅(九)
简介 sqilte是一个轻量级的数据库,满足数据库的基本操作,由于移动端的内存有限,所以sqilte刚好能满足移动端开发的基本要求. 废话不多说,上代码 1.首先介绍一下,sqlite的管理类SQLi ...
- Android学习笔记(十九) OkHttp
一.概述 根据我的理解,OkHttp是为了方便访问网络或者获取服务器的资源,而封装出来的一个工具包.通常的使用步骤是:首先初始化一个OkHttpClient对象,然后使用builder模式构造一个Re ...
随机推荐
- 【Ural1277】 Cops and Thieves 无向图点连通度问题
1277. Cops and Thieves Time limit: 1.0 secondMemory limit: 64 MB The Galaxy Police (Galaxpol) found ...
- [BSGS算法]纯水斐波那契数列
学弟在OJ上加了道"非水斐波那契数列",求斐波那契第n项对1,000,000,007取模的值,n<=10^15,随便水过后我决定加一道升级版,说是升级版,其实也没什么变化,只 ...
- 例10-2 uva12169(扩展欧几里得)
题意:已知xi=(a*xi-1+b) mod 10001,且告诉你x1,x3.........x2*t-1,让你求出其偶数列 思路: 枚举a,然后通过x1,x3求出b,再验证是否合适 1.设a, b, ...
- [bzoj4908][BeiJing2017]开车
来自FallDream的博客,未经允许,请勿转载,谢谢. 你有n辆车,分别a1, a2, ..., an位置和n个加油站,分别在b1, b2, ... ,bn .每个加油站只能支持一辆车的加油,所以你 ...
- Spring学习笔记2——创建Product对象,并在其中注入一个Category对象
第一步:创建Product类.在Product类中有对Category对象的set和get方法 package com.spring.cate; public class Product { priv ...
- JS 判断是否为IP格式
<html> <head> <title><a href='http://js.zz5u.net'><u>JavaScript</u& ...
- log4j日志的基本使用方法(1)——概述、配置文件
一.概述 Log4j由三个重要的组件构成:日志信息的优先级,日志信息的输出目的地,日志信息的输出格式.日志信息的优先级从高到低有ERROR.WARN.INFO.DEBUG,分别用来指定这条日志信息的重 ...
- 关于bedtools merge 功能中sort 命令的解释
Bedtools 是一个很好的用来处理区间的工具,很多时候用这个底层语言编写的小工具比自己写的脚本运行快很多,但是这个工具中的某些功能对输入文件有一定的要求,比如说里面的一个merge函数,这是里面的 ...
- Go 语言指向指针的指针
如果一个指针变量存放的又是另一个指针变量的地址,则称这个指针变量为指向指针的指针变量. 当定义一个指向指针的指针变量时,第一个指针存放第二个指针的地址,第二个指针存放变量的地址: 指向指针的指针变量声 ...
- 王家林人工智能AI课程大纲和电子书 - 老师微信13928463918
**3980元团购原价19800元的AI课程,团购请加王家林老师微信13928463918. 基于王家林老师独创的人工智能"项目情景投射"学习法,任何IT人员皆可在无需数学和Pyt ...