RadioGroup
     RadioButton的集合,提供多选一的机制
     属性:
  android:orientation="horizontal/vertical"
          vertical     垂直排布
          horizontal     水平排布          决定当前RadioGroup中RadioButton以什么形式排列
 
private RadioGroup rg ;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
               super.onCreate(savedInstanceState);
               rg=(RadioGroup) findViewById(R.id. radioGroup1);
               //实现RadioGroup的监听事件
               rg.setOnCheckedChangeListener( new OnCheckedChangeListener() {
                      @Override
                      public void onCheckedChanged(RadioGroup group, int checkedId) {
                            // TODO Auto-generated method stub
                            switch (checkedId) {
                            case R.id.radio :
                                  System. out.println();
                                   break;
                            case R.id.radio0 :
                                  System. out.println();
                                   break;
                            case R.id.radio1 :
                                  System. out.println();
                                   break;
                            default:
                                   break;
                            }
                     }
              });
       }
 
 
 <RadioGroup
        android:id="@+id/radioGroup1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
         >
 
        <RadioButton
            android:id="@+id/radio0"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="0" />
 
        <RadioButton
            android:id="@+id/radio1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="1" />
    </RadioGroup >

Android RadioGroup/RadioButton的更多相关文章

  1. [Android]--RadioGroup+RadioButton实现底部导航栏

    RadioGroup+RadioButton组合方式打造简单实用的底部导航栏 代码块: <?xml version="1.0" encoding="utf-8&qu ...

  2. Android RadioGroup和RadioButton详解

    实现RadioButton由两部分组成,也就是RadioButton和RadioGroup配合使用.RadioGroup是单选组合框,可以容纳多个RadioButton的容器.在没有RadioGrou ...

  3. android单选按钮选择,RadioGroup,radioButton

    android单选按钮选择,RadioGroup,radioButton 14. 四 / android基础 / 没有评论   单选布局绑定 如何识别选择

  4. Android RadioGroup的RadioButton 选择改变字体颜色和背景颜色

    RadioGroup <RadioGroup android:id="@+id/client_charge_radiogroup" android:layout_width= ...

  5. android.widget.RadioButton 单选按钮(转)

    大家好,我们今天这一节要介绍的是RadioGroup 的组事件.RadioGroup 可将各自不同的RadioButton ,设限于同一个Radio 按钮组,同一个RadioGroup 组里的按钮,只 ...

  6. Android 自定义RadioButton实现

    由于使用小米系统MIUI运行是RadioButton样式跟google Android API自定义的不一样,则我们可以定义任何想要的东东.没有做不到,只有想不到 Android 自定义RadioBu ...

  7. Android之RadioButton多行

    RadioGroup设置orientation="vertical"竖向单列显示 RadioGroup设置orientation="horizontal"横向单 ...

  8. Android——RadioGroup和CheckBox

    xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= ...

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

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

随机推荐

  1. android stuido 快捷键

    Alt+回车 导入包,自动修正 Ctrl+N   查找类 Ctrl+Shift+N 查找文件 Ctrl+Alt+L  格式化代码 Ctrl+Alt+O 优化导入的类和包 Alt+Insert 生成代码 ...

  2. .NET自动更新

    asp.net b/s就是布置在服务器的.你这个是要单机版的更新机制,博客园里面好几篇文章说这事呢. http://www.cnblogs.com/cnsharp/archive/2013/04/11 ...

  3. android Mvp简单实用

    View 对应于Activity,负责View的绘制以及与用户交互Model 依然是业务逻辑和实体模型Presenter 负责完成View于Model间的交互 模拟客户端的登录操作,并实现登录成功与登 ...

  4. HTML5新元素

    <figure> 标签规定独立的流内容(图像.图表.照片.代码等等). <figure> 元素的内容应该与主内容相关,同时元素的位置相对于主内容是独立的.如果被删除,则不应对文 ...

  5. java小型科学计算器

    /** * 1.先转换为逆波兰顺序 * 数字直接存入list,符号压入栈中,但是如果栈底元素不大于该运算符的运算顺序,则将栈底pop,直到大于栈底运算符为止,再压入栈中, * 最后将运算符依次全部po ...

  6. Android项目记录点滴2

    1.把本机地址广播出去private void sendIP() { try { DatagramSocket dgSocket = new DatagramSocket(8989); byte[] ...

  7. 适应多行长文本的Android TextView

    适应多行长文本的Android TextView

  8. 【Daily】 2014-4-28

    KEEP GOING  表达产品想法, 探讨产品问题, 倾听可能性问题. 一次就做好, 有成果展示, 主动展示 先确立图, 后确立代码. Hold dream, and never let it go ...

  9. poj2924---高斯求和

    #include <stdio.h> #include <stdlib.h> int main() { ; long long ans,a,b; scanf("%d& ...

  10. poj - 1228 - Grandpa's Estate

    题意:原来一个凸多边形删去一些点后剩n个点,问这个n个点能否确定原来的凸包(1 <= 测试组数t <= 10,1 <= n <= 1000). 题目链接:http://poj. ...