本文实例讲述了Android基于BaseExpandableListAdapter实现的二级列表仿通话记录功能。分享给大家供大家参考,具体如下:
android SDK中带有这样类似的例子,但是那个还是静态数据,没有实际应用价值,参考意义不大。
网上找了很多,还是那样的情况,几乎是同一篇文章,大家转来转去。况且,那篇例子也是静态的数据。
还是自己试试,自己写一个吧。程序读取手机系统的通话记录,按联系人分组,显示到列表。
开发工具:eclipse
运行环境:htc G9 android2.3.3
不多说,先看效果:
展开后的效果:
继续展开的效果:
main。xml:
& lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比; & lt; LinearLayout xmlns: android=" http://schemas.android.com/apk/res/android " android:取向=按怪薄? android: layout_width="宽和" android: layout_height="宽和" 比; & lt; ExpandableListView android: layout_width="宽和" android: layout_height="宽和" android: id=癅 + id/列表” android: groupIndicator=" @drawable/tubiao_button” android: layout_gravity=罢贰? android: indicatorRight=" 0 px”/比; & lt;/LinearLayout> >之前lis_item.xml:
& lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比; & lt;使用 xmlns: android=" http://schemas.android.com/apk/res/android " android: layout_width="宽和" android: layout_height="宽和" android: paddingLeft=" 2.0下降” 比; & lt; ImageView android: id=癅 + id/接触” android: layout_width=" wrap_content " android: layout_height=" wrap_content " android: src=" https://www.yisu.com/zixun/@drawable联系" android: layout_alignParentLeft=" true " android: layout_centerVertical=" true " android: layout_marginRight=" 10.0下降”/比; & lt; ImageView android: id=癅 + id/开放” android: layout_width=" wrap_content " android: layout_height=" wrap_content " android: src=" https://www.yisu.com/zixun/@drawable/分钟" android: layout_toRightOf=" @ id/接触” android: layout_centerVertical=" true " android: layout_marginLeft=" 5.0下降” android: layout_marginRight=" 5.0下降”/比; & lt; TextView android: id=癅 + id/名称” android: textAppearance=" & # 63; android: textAppearanceLarge” android: layout_width=" wrap_content " android: layout_height=" wrap_content " android: layout_marginLeft=" 10.0下降” android: layout_marginTop=" 5.0下降” android: layout_marginRight=" 10.0下降” android:单行模式=" true " android: layout_toRightOf=" @ id/开放” android: layout_alignTop=" @ id/开放”/比; & lt; ImageView android: id=癅 + id/类型” android: layout_width=" wrap_content " android: layout_height=" wrap_content " android: layout_marginTop=" 10.0下降” android: layout_marginRight=" 8.0下降” android: layout_marginLeft=" 5.0下降” android: src=" https://www.yisu.com/zixun/@drawable call_in " android: layout_alignParentRight=" true "/比; & lt; TextView android: id=癅 + id/计数” android: layout_width=" wrap_content " android: layout_height=" wrap_content " android: layout_marginTop=" 10.0下降” android: layout_marginRight=" 8.0下降” android: layout_marginLeft=" 10.0下降” android: layout_alignParentRight=" true "/比; & lt; TextView android: id=癅 + id/数量” android: textAppearance=" & # 63; android: textAppearanceSmall” android: ellipsize=罢信啤? android: layout_width=" wrap_content " android: layout_height=" wrap_content " android:单行模式=" true " android: layout_below=" @ id/名称” android: layout_alignLeft=" @ id/名称” android: layout_alignWithParentIfMissing=" true "/比; & lt; TextView android: id=癅 + id/日期” android: textAppearance=" & # 63; android: textAppearanceSmall” android: ellipsize=罢信啤? android: layout_width=" wrap_content " android: layout_height=" wrap_content " android:单行模式=" true " android: layout_alignParentBottom=" true " android: layout_alignParentRight=" true "/比; & lt;/RelativeLayout>Android基于BaseExpandableListAdapter实现的二级列表仿通话记录功能详解