Android ListView简单使用

Android ListView简单使用

最近的项目中用到了Listview,这里记录一下我的使用过程。

1 我的使用场景

在做项目的时候需要做一个历史记录的页面,这个应用每天会在固定的文件夹中生成一个txt文件,只需要把文件夹里面的内容显示在UI界面上,点击某个选项的时候再将文档中的内容显示再UI上就可以,问题比较简单,参考了几篇博客后顺利搞定。主要用到的是ListView控件,这里记录一下。

2 具体实现

首先看布局文件,这里写了两个布局,一个是整体的菜单布局,一个是菜单中的每个选项的布局,首先看整体菜单布局:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical"
    android:fadingEdge="vertical"
    android:background="#EDEDED">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:scrollbars="vertical">
        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:dividerHeight="1px"
            android:divider="#B8B8B8"
            android:id="@+id/history_listview">

        </ListView>
    </LinearLayout>

</ScrollView>

这里使用了简单的Scrollview再加上一个ListView,再来看选项的布局:

<LinearLayout xmlns:android=
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值