1。单选

.RadioGroup 可将各自不同的RadioButton ,设限于同一个Radio 按钮组,同一个RadioGroup 组里的按钮,只能做出单一选择(单选题).

 <RadioGroup  android:id="@+id/group"
android:orientation="horizontal">
<RadioButton android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="没过5年"
android:checked="true"
android:id="@+id/rdyear5"
/>
<RadioButton android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="过5年"
android:id="@+id/rdyearno5"
/>
</RadioGroup>

  .java

private RadioGroup group;
private RadioButton rb1 ;
private RadioButton rb2 ;
private boolean blflag; group=(RadioGroup) this.findViewById(R.id.group);
rb1=(RadioButton) this.findViewById(R.id.rdyear5);
rb2=(RadioButton) this.findViewById(R.id.rdyearno5);
group.setOnCheckedChangeListener(new checkedlistener()); public class checkedlistener implements RadioGroup.OnCheckedChangeListener{ @Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if(checkedId==R.id.rdyear5){
blflag=true;
}else if(checkedId==R.id.rdyearno5){
blflag=false;
}
} }

  

按钮 Button是各种UI中最常用的控件之一,它同样也是Android开发中最受欢迎的控件之一,用户可以通过触摸它来触发一系列事件,要知道一个没有点击事件的Button是没有任何意义的,因为使用者的固定思维是见到它就想去点!

<Button
android:id="@+id/btncal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="计算" />

.java

Button btncal=(Button) this.findViewById(R.id.btncal);  //获取该按钮控件
btncal.setOnClickListener(new listener()); //事件 private class listener implements View.OnClickListener{ @Override
public void onClick(View v) { } }

  

安卓学习之--UI控件用法 单选 按钮 下拉框的更多相关文章

  1. 自定义SWT控件四之其它下拉框

    4.其它下拉框 4.1 添加联动二级多选择框(有添加按钮和删除按钮) package com.view.control.select; import java.util.ArrayList; impo ...

  2. GridControl控件绑定RepositoryItemImageComboBox 作为下拉框使用

    如果,时间长时了,已前做过的东西,都记不得了,所以记录一下. 废话不多说. 1.拖出gridview控件,然后将字段绑定上去 2.将要做下拉框的控件加入RepositoryItemImageCombo ...

  3. devpress GridControl控件绑定RepositoryItemImageComboBox 作为下拉框使用 zt

    1.拖出gridview控件,然后将字段绑定上去 2.将要做下拉框的控件加入RepositoryItemImageComboBox控件 3.绑定数据 ; i < ; i++) { //如果取值时 ...

  4. Android简易实战教程--第二十二话《自定义组合控件模拟qq登录下拉框和其中的一些”小技巧”》

    转载此文章请注明出处:点击打开链接   http://blog.csdn.net/qq_32059827/article/details/52313516 首先,很荣幸此专栏能被CSDN推荐到主页.荣 ...

  5. Selenium常用API用法示例集----下拉框、文本域及富文本框、弹窗、JS、frame、文件上传和下载

    元素识别方法.一组元素定位.鼠标操作.多窗口处理.下拉框.文本域及富文本框.弹窗.JS.frame.文件上传和下载 元素识别方法: driver.find_element_by_id() driver ...

  6. 关于Devexpress15.2中GridControl控件选择字段ColumnEdit下拉时间设置

    效果:点击表格GridControl控件中的列,可以显示日期和时间.时间可以手动修改.(绑定日期格式的字段) 设置步骤:1.点击时间字段列表设置ColumnEdit-New-选择DateEdit出现r ...

  7. 模拟select控件,css模拟下拉

    <!DOCTYPE html > <head>     <meta http-equiv="Content-Type" content="t ...

  8. 使用谷歌提供的SwipeRefreshLayout下拉控件,并自定义实现下拉加载的功能

    package com.loaderman.swiperefreshdemo; import android.os.Bundle; import android.os.Handler; import ...

  9. 第一个开源控件:Google 官方下拉刷新控件 SwipeRefreshLayout 强化版,支持上拉刷新

    最近比较闲,所以趁着这时间撸了个SwipeRefreshLayout的加强版,Github地址. 原版只支持下拉刷新,强化之后支持上拉刷新和一进入页面就加载刷新,整个控件的加载动画是一致的,毫无违和感 ...

随机推荐

  1. tomcat启动报错No UserDatabase component found under key UserDatabase

    非正常关机,造成了tomcat下conf文件中的tomcat-user.xml文件异常,copy一个新的tomcat-user.xml覆盖就可以了.

  2. javase-->基础知识(二)

    1.算术运算符 7种:+,-,*,/,%,++,--;          --------------------注意不要想当然,按照类型规则来计算 ++在变量前,先加1再取变量使用 --同理 在变量 ...

  3. iOS JSON、NSDictionary互转

    #import "myCode.h" @implementation myCode /*! * @brief 把格式化的JSON格式的字符串转换成字典 * @param jsonS ...

  4. NGUI之UIRoot——屏幕的自适应分辨率的计算

    //原来写在其他博客上的东西,搬迁 预备知识: 要明确的三个概念: 设计分辨率:在编辑器上开发UI使用的分辨率.我们所有的UI都是在这个分辨率下设计制作的. 显示区域分辨率:设备上所显示的UI区域在编 ...

  5. XML 特殊字符

    XML转义字符 以下为XML标志符的数字和字符串转义符 "     (" 或 ") '     (' 或 &apos;) &     (& 或 & ...

  6. 实现移动设备远程登录linux服务器

    明天下午要考试了.所以最近时间有点紧,都在忙着看矩阵课本,刷刷题. 回到我们博客题目内容,最近正在看linux,之前是通过在笔记本上装着虚拟机的方法来进行操作. 之后发现一些能够进一步改进的地方,首先 ...

  7. Beginning Scala study note(9) Scala and Java Interoperability

    1. Translating Java Classes to Scala Classes Example 1: # a class declaration in Java public class B ...

  8. vs2010如何安装mvc3,怎样安装,详细的步骤,从哪下载?请看这篇文章。

    vs2010如何安装mvc3,怎样安装,详细的步骤,从哪下载?请看这篇文章. 安装步骤:vs2010 -> vs2010sp1 -> AspNetMVC3Setup -> AspNe ...

  9. LeetCode 387. First Unique Character in a String

    Problem: Given a string, find the first non-repeating character in it and return it's index. If it d ...

  10. Mysql在windows系统下的配置

    因为项目测试需求,不得不在本地装一个Mysql才能更方便地进行程序调试,整个过程虽然简单,但也遇到了一点麻烦,所以贴出来当是备忘. 这里采用MySQL Community Server  5.7.12 ...