精美ListView实例

最近由于需要开发一个基于android系统的小查询系统,直接从代码里面学习是最快的,确实通过三天的努力,系统完成了,中间走了不少弯路,但是起码东西是做出来了,有很多代码都是从这个论坛里下的,也没有什么回报的,只能上传一些学习过程中的代码了。
1.在如何使用ListView控件,有一篇文章(android ListView详解)给了我很大的帮助,我就不重新在这里再打一遍了,直接发网址:
http://www.cnblogs.com/allin/archive/2010/05/11/1732200.html
2.该代码的效果图1如下:
094441fyvzjqp6odhdyz6v.bmp

main.xml的代码如下:

  1. <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
  2.          android:orientation="vertical" android:layout_width="fill_parent"
  3.          android:layout_height="fill_parent"
  4.          android:background="#253853"
  5.          >

  6.         <listview android:id="@+id/list"
  7.           android:layout_width="match_parent"
  8.           android:layout_height="match_parent"
  9.        android:layout_marginBottom="10dp"         
  10.            android:cacheColorHint="#00000000"
  11.            android:divider="#2A4562"
  12.            android:dividerHeight="4px"
  13.            android:listSelector="#264365"
  14.            android:drawSelectorOnTop="false"
  15.            >
  16.          
  17.      



复制代码
list_item.xml的代码如下:

  1. <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
  2.                          android:layout_width="fill_parent"
  3.                         android:layout_height="fill_parent"
  4.                          android:background="@drawable/selector"
  5.                          >
  6.                                                 
  7.             <imageview android:id="@+id/img"
  8.                          android:layout_width="wrap_content"
  9.                         android:layout_height="wrap_content"                        
  10.                         android:layout_gravity="center_vertical"
  11.                          android:layout_marginLeft="20dp"                        
  12.                         />
  13.                         
  14.         <linearlayout android:orientation="vertical"
  15.                 android:layout_width="fill_parent"  
  16.                  android:layout_height="wrap_content">
  17.                                                                  
  18.                 <textview android:text="data" android:id="@+id/title"
  19.                          android:layout_width="fill_parent"
  20.                         android:layout_height="wrap_content"
  21.                         android:gravity="center_vertical"  
  22.                          android:layout_marginLeft="20dp"
  23.                         android:layout_marginTop="20dp"
  24.                         android:textSize="14sp"                                                
  25.                         android:textStyle="bold"
  26.                          android:textColor="@color/black"                                                
  27.                         >
  28.                                          
  29.    


复制代码
selector的代码如下:



  1.         
  2.                  
  3.                          <gradient android:angle="270" android:endcolor="#99BD4C"
  4.                                  android:startColor="#A5D245" />
  5.                          <padding android:left="15dp" android:top="20dp"
  6.                                  android:right="15dp" android:bottom="20dp" />

  7.                         

  8.                         

  9.                
  10.          
  11.          
  12.                  
  13.                          <gradient android:angle="270" android:endcolor="#99BD4C"
  14.                                  android:startColor="#A5D245" />
  15.                          <padding android:left="15dp" android:top="20dp"
  16.                                  android:right="15dp" android:bottom="20dp" />

  17.                         

  18.                         

  19.                
  20.          
  21.          
  22.                  
  23.                          <gradient android:angle="270" android:endcolor="#A8C3B0"
  24.                                  android:startColor="#C6CFCE" />
  25.                          <padding android:left="15dp" android:top="20dp"
  26.                                  android:right="15dp" android:bottom="20dp" />

  27.                         

  28.                         

  29.                

  30.         



复制代码
对于只修改一个其中的几个颜色就能实现各种不同的listview风格,肯定比处理图片轻松多了

4.有兴趣可以下载看看:

CustomList.rar(691.73 KB, 下载次数: 524)

23025113q3r45oqrrrgg1r.bmp
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值