教你制作表格样式的ListView

本文介绍了如何在项目中创建一个展示项目明细的表格样式ListView。通过结合HorizontalScrollView解决单条信息过长的问题,实现屏幕横向滚动。文章分享了ListView适配器的list_item.xml布局和activity_main.xml布局,强调了代码规范性和降低耦合性的实践。
摘要由CSDN通过智能技术生成

最近在做工作流的项目,项目开发中需要把项目的明细用表格的样式展示在ListView控件上,前前后后测试了几个demo运用到项目中,感觉相当佩服他们,所以也尝试着学习他们自己制作了一个demo,就当自娱自乐,仅供参考。你们也可以参考以下博客:

http://blog.csdn.net/bewhatyouare/article/details/8373584

http://www.diannao.wang/anzhuo/2015/52-81030.html

项目中由于单条信息过长,一个屏幕不可能完全展示出来,所以用到了HorizontalScrollView控件,此控件可以实现屏幕的横向滚动。

项目开发中ListView适配器的布局界面list_item.xml如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/name"
        style="@style/itemStyle"
        android:layout_width="140dp" />

    <View
        style="@style/viewStyle"
        android:visibility="visible" />

    <TextView
        android:id="@+id/age"
        style="@style/itemStyle"
        android:layout_width="70dp" />

    <View
        style="@style/viewStyle"
        android:visibility="visible" />

    <TextView
        android:id="@+id/height"
        style="@style/itemStyle"
        android:layout_width="55dp" />

    <View
        style="@style/viewStyle"
        android:visibility="visible" />

    <TextView
        android:id="@+id/weight"
        style="@style/itemStyle"
        android:layout_width="150dp" />

    <View
        style="@style/viewStyle"
        android:visibility="visible" />

    <TextView
        android:id="@+id/school"
        style="@style/itemStyle"
        android:layout_width="150dp" />


</LinearLayout>

Activity用到的布局界面activity_main.xml如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#fff
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值