单选按钮和复选框在实际中经常看到,今天就简单梳理下。

首先,我们在工具中拖进单选按钮RadioGroup和复选框Checkbox,如图:

xml对应的源码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<RadioButton
android:id="@+id/rightbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="对" />

<RadioButton
android:id="@+id/falsebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="错" />

<CheckBox
android:id="@+id/run_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="跑步" />

<CheckBox
android:id="@+id/read_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="看书" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="设置" />

</LinearLayout>

我们修改下RadioButton部分代码改成:

<RadioGroup
android:id="@+id/judge"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<RadioButton
android:id="@+id/rightbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="对" />

<RadioButton
android:id="@+id/falsebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="错" />
</RadioGroup>

效果如下:

3.Android之单选按钮RadioGroup和复选框Checkbox学习的更多相关文章

  1. Android 单选按钮(RadioButton)和复选框(CheckBox)的使用

    1.RadioButton (1)介绍 (2)单选按钮点击事件的用法 (3)RadioButton与RadioGroup配合使用实现单选题功能 (4)xml布局及使用 <?xml version ...

  2. Android初级教程小案例之单选框RadioGroup与复选框CheckBox

    Android里面的单选框和html中的其实是一样的效果.这里用到两个控件:CheckBox和RadioGroup.直接上代码: radio.xml布局文件: <?xml version=&qu ...

  3. 关于bootstrap--表单(下拉<select>、输入框<input>、文本域<textare>复选框<checkbox>和单选按钮<radio>)

    html 里面的 role 本质上是增强语义性,当现有的HTML标签不能充分表达语义性的时候,就可以借助role来说明.通常这种情况出现在一些自定义的组件上,这样可增强组件的可访问性.可用性和可交互性 ...

  4. 安卓开发:UI组件-RadioButton和复选框CheckBox

    2.5RadioButton 为用户提供由两个及以上互斥的选项组成的选项集. 2.5.1精简代码 在按钮变多之后,多次重复书写点击事件有些繁琐,我们在这里创建一个事件OnClick,每次点击时调用该事 ...

  5. css3美化复选框checkbox

     两种美化效果如下图: 代码(html) <div id="main"> <h2 class="top_title">使用CSS3美化复 ...

  6. [原创]纯JS实现网页中多选复选框checkbox和单选radio的美化效果

    图片素材: 最终效果图: <html><title> 纯JS实现网页中多选复选框checkbox和单选radio的美化效果</title><head>& ...

  7. 复选框(checkbox)、单选框(radiobox)的使用

    复选框(checkbox).单选框(radiobox)的使用 复选框: HTML: // 复选框 <input type="checkbox" name="chec ...

  8. php 判断复选框checkbox是否被选中

    php 判断复选框checkbox是否被选中   复选框checkbox在php表单提交中经常被使用到,本文章通过实例向大家介绍php如何判断复选框checkbox中的值是否被选中,需要的朋友可以参考 ...

  9. jquery判断复选框checkbox是否被选中

    jquery判断复选框checkbox是否被选中 使用is方法 //如果选中返回true //如果未选中返回false .is(':checked');

随机推荐

  1. POJ 1151 Atlantis 线段树求矩形面积并 方法详解

    第一次做线段树扫描法的题,网搜各种讲解,发现大多数都讲得太过简洁,不是太容易理解.所以自己打算写一个详细的.看完必会o(∩_∩)o 顾名思义,扫描法就是用一根想象中的线扫过所有矩形,在写代码的过程中, ...

  2. 2D Tookit (一) 精灵切割

    Sprite Dicing 精灵切割 图一:原图 Diced 设置   Diced[切割]对比图 文档 http://www.2dtoolkit.com/docs/latest/advanced/sp ...

  3. sqlzoo.net刷题3

    Find the continents where all countries have a population <= 25000000. Then find the names of the ...

  4. 在Centos5下安装GraphicsMagick

    安装GraphicsMagick的流水账: 安装参照的http://www.graphicsmagick.org/INSTALL-unix.html 解压 /home/milton/GraphicsM ...

  5. C语言 预处理三(条件编译--#if)

    //#if 条件编译 //一般用于产品各个版本的语言包 #include<stdio.h> #include<stdlib.h> //#都是预处理指令,条件表达式必须在预处理里 ...

  6. 2016国产恐怖惊悚《诡娃》HD720P.国语中字

    导演: 蒋国权编剧: 任旭东主演: 李抒航 / 程媛媛 / 孔维类型: 惊悚 / 恐怖制片国家/地区: 中国大陆语言: 汉语普通话上映日期: 2016-02-25(中国大陆)片长: 89分钟诡娃的剧情 ...

  7. 【OpenGL】查看显卡对OpenGL的支持程度

    由于开发工作中要用到OpenGL的API进行渲染,公司配的电脑又是集成显卡,所以想知道显卡对OpenGL的支持程度. 下面介绍的方法就解决了这一点. 1.下载安装EVEREST Ultimate Ed ...

  8. Python之socket(套接字)

    Socket 一.概述 socket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,应用程序通常通过"套接字"向网络发出请求或者应答网络请求. ...

  9. [MetaHook] R_SparkShower

    By hzqst void R_SparkShower(float *pos) { TEMPENTITY *tent; tent = efx.CL_TempEntAllocNoModel(pos); ...

  10. 20145324 20145325《信息安全系统设计基础》实验五 简单嵌入式WEB服务器实验

    实验五报告链接为:http://www.cnblogs.com/SJZGM10/p/6106668.html