RadioGroup动态添加RadioButton,并且获得事件
来源:互联网 发布:今日目标软件功能 编辑:程序博客网 时间:2024/05/16 05:35
1、添加RadioButton到RadioGroup中
[java] view plain copy
- RadioGroup group;
- for(int i=0; i<10; i++)
- {
- RadioButton tempButton = new RadioButton(this);
- tempButton.setBackgroundResource(R.drawable.xxx); // 设置RadioButton的背景图片
- tempButton.setButtonDrawable(R.drawable.xxx); // 设置按钮的样式
- tempButton.setPadding(80, 0, 0, 0); // 设置文字距离按钮四周的距离
- tempButton.setText("按钮 " + i);
- group.addView(tempButton, LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
- }
2、为RadioGroup添加事件处理,可以得到当前选择的RadioButton
[java] view plain copy
- group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(RadioGroup group, int checkedId) {
- // TODO Auto-generated method stub
- RadioButton tempButton = (RadioButton)findViewById(checkedId); // 通过RadioGroup的findViewById方法,找到ID为checkedID的RadioButton
- // 以下就可以对这个RadioButton进行处理了
- }
- });
0 0
- RadioGroup动态添加RadioButton,并且获得事件
- RadioGroup动态添加RadioButton,并且获得事件
- RadioGroup动态添加RadioButton,并且获得事件
- RadioGroup中动态添加RadioButton
- android中radioGroup动态添加radioButton
- RadioGroup中动态添加RadioButton,RadioButton状态紊乱
- RadioGroup中添加RadioButton
- Android 代码中动态为RadioGroup添加RadioButton
- Dialog中存在radiogroup动态添加radiobutton的ID问题
- RadioGroup 和 RadioButton 点击事件
- RadioGroup 中 RadioButton 单击事件
- 自定义RadioGroup动态添加RadioButton,并获取选中radioButton的位置
- 动态在RadioGroup加载RadioButton
- 在RadioGroup动态添加RadioButton,在构造方法里添加style。
- android 动态添加组件(RadioGroup 添加RadioButton和其他组件的一些问题)
- 动态添加RadioGroup组件的RadioButton出现多选状况解决
- Android中RadioGroup在代码中动态添加子控件RadioButton
- 给gridview动态生成radiobutton添加OnCheckedChanged事件
- Android DialogFragment偶发不能清除的问题
- 百度地图改变定位图标
- 6个输入框背后的47个设计点
- PAT (Basic Level) Practise (中文)1047. 编程团体赛(20)
- appium测试之滑动操作
- RadioGroup动态添加RadioButton,并且获得事件
- HDU 4500 小Q系列故事——屌丝的逆袭(水题)
- html5本地存储webstorage
- Android简洁架构设计 The Clean Architecture
- webview组件的一些方法
- hadoop :mkdir: 'input': No such file or directory 相关问题
- linux 设置IP DNS 网关
- ubuntu下搭建web服务器(MySQL+PHP+Apache2)
- Java 获取鼠标点击坐标