巧用CheckedTextView完成自定义radiobutton的listview
因为要用自定义图片的radiobutton的listview,最开始想自己重新写BaseAdapter,重新定义BaseAdapter中的每个list的item。总之android提供了太多方便的控件,就想用他自己的,所以我发现了CheckedTextView。
自己定义的layout文件
list_item_single_choice.xml
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:checkMark="@drawable/radiobuttonstyle
android:gravity="center_vertical"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="@color/textcolor_select"
android:textSize="22sp" />
其中checkmark就是自己定义radiobutton的drawable
radiobuttonstyle.xml定义如下
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/system_seat_setting_on" android:state_checked="true"></item>
<item android:drawable="@drawable/system_seat_setting_on" android:state_selected="true"></item>
<item android:drawable="@drawable/system_seat_setting_on" android:state_pressed="true"></item>
<item android:drawable="@drawable/system_seat_setting_off"></item>
</selector>
这样自己就不需要重新写adapte了。
代码里实现如下
mListView.setAdapter(new ArrayAdapter<String>(context,R.layout.list_item_single_choice, Arraystring));
直接用了系统的ArrayAdapter就可以啦~~
巧用CheckedTextView完成自定义radiobutton的listview的更多相关文章
- Android 自定义RadioButton的样式
Android 自定义RadioButton的样式 我们知道Android控件里的button,listview可以用xml的样式自定义成自己希望的漂亮样式. 最近用到RadioButton,利用xm ...
- Android 自定义RadioButton实现
由于使用小米系统MIUI运行是RadioButton样式跟google Android API自定义的不一样,则我们可以定义任何想要的东东.没有做不到,只有想不到 Android 自定义RadioBu ...
- 【转】Android自定义Adapter的ListView的思路及代码
原文网址:http://www.jb51.net/article/37236.htm Android自定义Adapter的ListView的思路及代码,需要的朋友可以参考一下 在开发中,我们经常使 ...
- 【Android基础】listview控件的使用(4)-----自定义布局的listview的使用
前面我介绍了listview控件的不同用法,但是这些用法在实际的开发项目中是不足以满足需求的,因为前面的几种用法只能简单的显示文本信息,而且布局都比较单一,很难做出复杂的结果,在实际的开发项目中,90 ...
- 【swift,oc】ios开发中巧用自动布局设置自定义cell的高度
ios开发中,遇到自定义高度不定的cell的时候,我们通常的做法是抽取一个frame类,在frame类中预算好高度,再返回. 但是苹果出来自动布局之后...春天来了!!来看看怎么巧用自动布局设置自定义 ...
- 使用自定义RadioButton和ViewPager实现TabHost效果和带滑动的页卡效果
在工作中又很多需求都不是android系统自带的控件可以达到效果的,内置的TabHost就是,只能达到简单的效果 ,所以这个时候就要自定义控件来达到效果:这个效果就是: 使用自定义RadioButto ...
- wpf radiobuttong 去前面的圆点, 自定义radiobutton样式
自定义radiobutton样式代码: <windows.Resources> <LinearGradientBrush x:Key="CheckRadioFillNorm ...
- FastReport自定义数据源及ListView控件的使用
##1.想批量生成一堆物资信息卡,效果如下图所示,fastreport可以一下全部生成,并且发现不用单独写东西, ##2.发现FastReport官方给出的Demo.exe很友好,基本可以满足要求,想 ...
- 【转】Android之自定义Adapter的ListView
http://www.cnblogs.com/topcoderliu/archive/2011/05/07/2039862.html 在开发中,我们经常使用到ListView这个控件.Android的 ...
随机推荐
- LightOJ 1234 Harmonic Number(打表 + 技巧)
http://lightoj.com/volume_showproblem.php?problem=1234 Harmonic Number Time Limit:3000MS Memory ...
- centos 7 安装mysql5.6rpm格式
1查看是否安装了mysql rpm -qa|grep -i mysql 如果安装了请卸载:rpm -e --nodeps MySQL... 2.没有安装则进行如下操作 下载mysql rpm ta ...
- 南昌网络赛 I. Max answer 单调栈
Max answer 题目链接 https://nanti.jisuanke.com/t/38228 Describe Alice has a magic array. She suggests th ...
- 4.client、offset、scroll系列
client.offset.scroll系列 他们的作用主要与计算盒模型.盒子的偏移量和滚动有关 clientTop 内容区域到边框顶部的距离 ,说白了,就是边框的高度 clientLeft 内容区域 ...
- [ActionScript 3.0] 像素级碰撞检测
package { import flash.display.BitmapData; import flash.display.BlendMode; import flash.display.Disp ...
- jquery源码解析:jQuery原型方法init的详解
先来了解几个jQuery方法: <li></li> <li></li> <li></li> $("li") ...
- jmeter聚合报告详解
聚合报告(aggregate report) 对于每个请求,它统计响应信息并提供请求数,平均值,最大,最小值,错误率,大约吞吐量(以请求数/秒为单位)和以kb/秒为单位的吞吐量. 吞吐量是以取样目标点 ...
- Intellig IDEA 搭建spring boot 热部署
在pom中直接引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactI ...
- Shell基本知识
Shell是什么 Shell是一个命令行解释器,它为用户提供了一个向Linux内核发送请求以便运行程序的界面系统级程序,用户可以使用Shell来启动.挂起.停止甚至编写一些程序. Shell还是一个功 ...
- Nginx反向代理与负载简单实现
反向代理 1.proxy_pass 通过反向代理把请求转发到百度 2.proxy_pass 既可以是ip地址,也可以是域名,同时还可以指定端口 3.proxy_pass 指定的地址携带了URI,如果前 ...