绥江一百http://www.sj100.net                                                  欢迎,进入绥江一百感谢点击[我的小网站,请大家多多指教相互共勉]

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

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

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:andro
 3     android:layout_width="fill_parent"
 4     android:layout_height="fill_parent"
 5     android:orientation="vertical" >
 6 
 7     <TextView
 8         android:
 9         android:layout_width="fill_parent"
10         android:layout_height="wrap_content"
11         android:text="@string/hello" />
12 
13     <Button
14         android:
15         android:layout_width="wrap_content"
16         android:layout_height="wrap_content"
17         android:text="向上" />
18 
19     <ListView
20         android:
21         android:layout_width="match_parent"
22         android:layout_height="wrap_content" >
23 
24     </ListView>
25 
26 </LinearLayout>
main.xml

相关文章: