首页 > 移动平台 > 详细

Android RadioGroup/RadioButton

时间:2015-09-22 18:07:08      阅读:245      评论:0      收藏:0      [点我收藏+]
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

原文:http://www.cnblogs.com/stareblankly/p/4829247.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!