RadioGroup修改默认小圆点
来源:互联网 发布:aso优化 app排名 编辑:程序博客网 时间:2024/06/05 10:53
1.使用XML文件进行定义选择器 res/drawable/radio.xml
- <?xml
version="1.0" encoding="utf-8"?> - <selector
xmlns:Android="http://schemas.android.com/apk/res/android"> - <!--
未选中- > -
-
-
/> - <!--选中->
-
-
-
/> - </selector>
- <RadioGroup
-
... - >
- <RadioButton
-
... - android:button="@null"
- android:background="@drawable/radio"
- />
- </RadioGroup>
android:background="@drawable/radio"使用定义的样式
3.
4,为radioGroup添加监听事件,用来监听组件内部的事件响应:
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
4,为radioGroup添加监听事件,用来监听组件内部的事件响应:
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
为radioGroup添加监听事件,用来监听组件内部的事件响应:
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
为RadioGroup增加监听事件,作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
4.代码
<RadioGroup android:id="@+id/grade_group" android:paddingLeft="15dp" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <RadioButton android:id="@+id/class_small" android:background="@drawable/selector_radiogroup" android:button="@null" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:id="@+id/small" android:layout_gravity="center_vertical" android:layout_marginLeft="12dp" android:paddingRight="60dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="小班" android:textSize="15dp"/> <RadioButton android:id="@+id/class_middle" android:background="@drawable/selector_radiogroup" android:button="@null" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:id="@+id/middle" android:layout_gravity="center_vertical" android:paddingRight="60dp" android:layout_marginLeft="12dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="中班" android:textSize="15dp"/> <RadioButton android:id="@+id/class_big" android:background="@drawable/selector_radiogroup" android:button="@null" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:id="@+id/big" android:layout_gravity="center_vertical" android:layout_marginLeft="12dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="大班" android:textSize="15dp"/></RadioGroup>
rg_group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (rb_small.getId() == checkedId) { grade = small.getText().toString(); } else if (rb_middle.getId() == checkedId) { grade = middle.getText().toString(); }else if(rb_big.getId() == checkedId){ grade = big.getText().toString(); } }});
privateRadioGroup mSex_group;private RadioButton mMale;private RadioButton mFemale;private String sexName; mSex_group= (RadioGroup) findViewById(R.id.sex_group); mMale = (RadioButton) findViewById(R.id.male); mFemale = (RadioButton) findViewById(R.id.female); mSex_group.setOnCheckedChangeListener(newRadioGroup.OnCheckedChangeListener(){ @Overridepublic void onCheckedChanged(RadioGroupgroup,int checkedId){ if(mMale.getId()== checkedId){ sexName = mMale.getText().toString();} elseif (mFemale.getId()== checkedId){ sexName = mFemale.getText().toString();} }});
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
privateRadioGroup mSex_group;private RadioButton mMale;private RadioButton mFemale;private String sexName; mSex_group= (RadioGroup) findViewById(R.id.sex_group); mMale = (RadioButton) findViewById(R.id.male); mFemale = (RadioButton) findViewById(R.id.female); mSex_group.setOnCheckedChangeListener(newRadioGroup.OnCheckedChangeListener(){ @Overridepublic void onCheckedChanged(RadioGroupgroup,int checkedId){ if(mMale.getId()== checkedId){ sexName = mMale.getText().toString();} elseif (mFemale.getId()== checkedId){ sexName = mFemale.getText().toString();} }});
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
privateRadioGroup mSex_group;private RadioButton mMale;private RadioButton mFemale;private String sexName; mSex_group= (RadioGroup) findViewById(R.id.sex_group); mMale = (RadioButton) findViewById(R.id.male); mFemale = (RadioButton) findViewById(R.id.female); mSex_group.setOnCheckedChangeListener(newRadioGroup.OnCheckedChangeListener(){ @Overridepublic void onCheckedChanged(RadioGroupgroup,int checkedId){ if(mMale.getId()== checkedId){ sexName = mMale.getText().toString();} elseif (mFemale.getId()== checkedId){ sexName = mFemale.getText().toString();} }});
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
privateRadioGroup mSex_group;private RadioButton mMale;private RadioButton mFemale;private String sexName; mSex_group= (RadioGroup) findViewById(R.id.sex_group); mMale = (RadioButton) findViewById(R.id.male); mFemale = (RadioButton) findViewById(R.id.female); mSex_group.setOnCheckedChangeListener(newRadioGroup.OnCheckedChangeListener(){ @Overridepublic void onCheckedChanged(RadioGroupgroup,int checkedId){ if(mMale.getId()== checkedId){ sexName = mMale.getText().toString();} elseif (mFemale.getId()== checkedId){ sexName = mFemale.getText().toString();} }});
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
privateRadioGroup mSex_group;private RadioButton mMale;private RadioButton mFemale;private String sexName; mSex_group= (RadioGroup) findViewById(R.id.sex_group); mMale = (RadioButton) findViewById(R.id.male); mFemale = (RadioButton) findViewById(R.id.female); mSex_group.setOnCheckedChangeListener(newRadioGroup.OnCheckedChangeListener(){ @Overridepublic void onCheckedChanged(RadioGroupgroup,int checkedId){ if(mMale.getId()== checkedId){ sexName = mMale.getText().toString();} elseif (mFemale.getId()== checkedId){ sexName = mFemale.getText().toString();} }});
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
作者: thermos
链接:http://www.imooc.com/article/2598
来源:慕课网
0 0
- RadioGroup修改默认小圆点
- 小圆点+XlistView+RadioGroup
- RadioButton去掉默认样式小圆点
- RadioButton去掉默认样式小圆点
- 小圆点
- 小圆点
- 小圆点
- 小圆点
- ios-runtime(swift)使用,修改pageControl的小圆点
- ViewPager加小圆点
- 代码实现小圆点
- 轮滑加小圆点
- 绘制轮播图小圆点
- ViewPager+小圆点
- viewpager加小圆点
- 图片轮播加小圆点
- 轮播小圆点
- vieapager小圆点
- USB免驱摄像头采集图像【VS2012+opencv+directShow(CcameraDS)实现】
- 混合移动应用中地图导航功能开发与应用
- Git 学习(篇四 --Git别名)
- Javascript高级ajax、jsonp
- LeetCode: Generate Parentheses
- RadioGroup修改默认小圆点
- 说说MQ集群这件小事
- 思维 hdu 1847 (Good Luck in CET-4 Everybody!)
- 算法总结——大整数加法
- Git查看某一个文件的修改记录(提交记录)
- 括号匹配算法
- java设计模式,享元模式
- Android Studio 使用小技巧和快捷键
- 实用文章收集