实现多行RadioGroup
来源:互联网 发布:手机怎么设置淘宝联盟 编辑:程序博客网 时间:2024/05/03 00:52
Android中的RadioGroup只能横向或者纵向单行摆放。实现多行RadioGroup实际上是使用了多个RadioGroup,而同时只能有一个RadioGroup起作用。
原文地址:http://www.tutorialforandroid.com/2009/11/select-radiobutton-from-multiple.html
Select a RadioButton from Multiple RadioGroup in Android
private Boolean changeGroup = false;public void onCheckedChanged(RadioGroup group, int checkedId){ if (group != null && checkedId > -1 && changeGroup == false){ if(group == frequencyGroup1){ changeGroup = true; frequencyGroup2.clearCheck(); frequencyGroup3.clearCheck(); changeGroup = false; }else if(group == frequencyGroup2){ changeGroup = true; frequencyGroup1.clearCheck(); frequencyGroup3.clearCheck(); changeGroup = false; }else if(group == frequencyGroup3){ changeGroup = true; frequencyGroup1.clearCheck(); frequencyGroup2.clearCheck(); changeGroup = false; } }}
Explanation
Create a flag stating that we mark as whether the function could be execute or not (see below)
private Boolean changeGroup = false;
On the default change function of RadioGroup, create a conditional statement that would execute the change function of all RadioGroup only when our flag state that it can execute the next code block. By default this function will execute when you select a RadioButton on a Group and/or when you call clearCheck() of each RadioGroup, and you may not want to do that especially when we call clearCheck.
if (group != null && checkedId > -1 && changeGroup == false){
The following code will just set the flag to true when users select a RadioButton on any group, thus when other RadioGroup call clearCheck() the code block in the function will not be called.
.....
0 0
- 实现多行RadioGroup
- RadioGroup实现单选框的多行排列
- 自定义多行RadioGroup控件实现记录
- 自定义RadioGroup实现多行排列
- Android 自定义View实现多行RadioGroup单选(多选)
- Android 自定义View实现多行RadioGroup (MultiLineRadioGroup)
- RadioGroup的多行布局
- RadioGroup实现多行多列 不重写RadioGroup
- RadioGroup实现底部导航
- viewPager+radiogroup实现关联
- 自定义RadioGroup 实现选择
- 自定义支持多行显示的RadioGroup
- android支持多行的radiogroup
- RadioGroup的多行显示RadioButton
- 基于RadioGroup的TabHost实现
- 实现RadioGroup控件使用,单选框。
- RadioGroup中的RadioButton实现换行
- 自定义RadioGroup实现radioButton多行多列
- 一些grep, sed, awk命令的练习题
- hdu 4941 Magical Forest 多校第七场
- 2014年自助建站平台是一个正在变得拥挤的市场?
- Android Handler 异步消息处理机制的妙用 创建强大的图片加载类
- poj 1962 Corporative Network 带权并茶集
- 实现多行RadioGroup
- myeclispe Tomcat中deploy时deploy location跟项目名称不一样
- Jenkins实现远程部署Web项目
- attr和style相关的自定义
- VLC 使用live555 接收数据
- linux命令
- UVA - 375 Inscribed Circles and Isosceles Triangles
- 看代码如果看到while(1) 加上switch case,就是状态机
- chart.js操作实例(前后台互通)