Android列表方法,Android通过LIstView显示文件列表的两种方法介绍

本文介绍了如何在Android中使用ListView显示SD卡文件列表的两种方法,重点讲解了通过继承BaseAdapter的方法。包括XML界面设计、BaseAdapter类的实现以及File_listActivity的创建。详细步骤和注意事项有助于理解文件列表的显示机制。
摘要由CSDN通过智能技术生成

在Android中通过ListView显示SD卡中的文件列表一共有两种方法,一是:通过继承ListActivity显示;二是:利用BaseAdapter显示。BaseAdapter是一个公共基类适配器,用于对ListView和Spinner等 一些控件提供显示数据。下面是利用BaseAdapter类来实现通过LIstView显示SD卡的步骤:

1.main.xml界面设计,如下图

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical" >

android:id="@+id/Txt_Path"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/hello" />

android:id="@+id/But_Up"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="向上" />

android:id="@+id/List_View"

android:layout_width="match_parent"

android:layout_height="wrap_content" >

main.xml

2.item.xml界面设计,如下图

android:id="@+id/RelativeLayout1"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

android:id="@+id/Txt_Size"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentRight="true"

android:layout_alignParentTop="true"

android:text="TextView" />

android:id="@+id/image_ico"

android:layout_width="wrap_content"

android:layout_height="wrap_co

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值