zoukankan      html  css  js  c++  java
  • Android RadioGroup/RadioButton

    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 >
    stareblankly.cn
  • 相关阅读:
    一、HTML基础学习
    算法之求正整数的二进制
    JavaScript ajax返回状态
    ajax实现异步校验
    比较喜欢的一种求阶乘的方法:用递归求阶乘
    java中自定义异常类
    我对多态的理解
    包装类和基本类型区别?(integer和int取值范围一样大)
    JAVA中默认的编码方式
    抽象类和接口的区别
  • 原文地址:https://www.cnblogs.com/stareblankly/p/4829247.html
Copyright © 2011-2022 走看看