- final RadioButton radioButton;
- radioButton = new RadioButton(context);
虽说这样效率有点低,但是有时候我们需要则断一下,只要能实现效果,偶尔对性能放下水也是OK的,何况这种情况下不可能有那么多列.
项目实现样式:

看起来还凑合吧。
这里我把代码上传一下,不足的地方,自己可以进行调整,我只是提供个思路.
利用RMAN对数据库进行备份与恢复 PPT文档下载地址
免费下载地址在 http://linux.linuxidc.com/
用户名与密码都是www.linuxidc.com
具体下载目录在 /2012年资料/8月/26日/Android 自定义RadioButton(单选按钮)图标随便定
第二种方法:对RadioButton给定样式进行改造
看配置文件
seletor.xml and style.xml
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@drawable/radio_checked" android:state_checked="true" android:state_enabled="true"></item>
- <item android:drawable="@drawable/radio_unchecked" android:state_checked="false" android:state_enabled="true"></item>
- </selector>
- <resources xmlns:android="http://schemas.android.com/apk/res/android">
- <style name="RadioButtonStyles">
- <item name="android:button">@drawable/selector</item>
- </style>
- </resources>
- <RadioGroup
- android:id="@+id/rg_main"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
- <RadioButton
- android:id="@+id/button1"
- style="@style/RadioButtonStyles"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="5K" />
- <RadioButton
- android:id="@+id/button2"
- style="@style/RadioButtonStyles"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="10K" />
- </RadioGroup>
这种方式很简单吧,不过我觉的应用范围没有上面自定义来的广,比如说上面我做的项目中,RadioButton中的text有两项,这样我们用RadioButton就无法实现了,遇到比较复杂的RadioButton选择自定义是比较好的.
针对RadioButton 就说这么多了,希望对你有帮助.

