RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
RaidoButton单选框

应用场景:实现单选效果    eg:问卷调查  性别选中   

成都创新互联专注于郸城企业网站建设,自适应网站建设,商城网站开发。郸城网站建设公司,为郸城等地区提供建站服务。全流程按需定制开发,专业设计,全程项目跟踪,成都创新互联专业和态度为您提供的服务

xml:

RadioButton

 android:checked="true"      设置是否     选中 

 android:text="RadioButton" 文本

  注意:

RaidoButton要实现单选效果必须放在RadioGroup中

RadioGroup设置方向:

android:orientation="horizontal"  水平

code:

//获得RadioGroup

RadioGroup mGroup=(RadioGroup) findViewById(R.id.radioGroup1);

//获得被选中的RadioButtonId

int checkedRadioButtonId = mGroup.getCheckedRadioButtonId();

//查找选中的RadioButton

RadioButton button = (RadioButton) findViewById(checkedRadioButtonId);

//获得选中的RadioButton的文本

String string = button.getText().toString();


//设置RadioButton状态改变监听事件

mGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override

            public void onCheckedChanged(RadioGroup group, int checkedId) {

                //获得被选中的RadioButton

                RadioButton button = (RadioButton) findViewById(checkedId);

                //获得选中的RadioButton的文本

                String string = button.getText().toString();

                mTv.setText(string);

            }

        });


分享名称:RaidoButton单选框
网站路径:http://cqwzjz.cn/article/jggdgh.html