0
我想顯示一個使用ArrayAdapter到ListView的文件列表。盡我所知,以下應該可以工作,但它只是將ListView留空。我沒有使用ListActivity。爲什麼我的列表視圖不顯示?
的Java
setContentView(R.layout.files);
findViewById(R.id.folder_use).setOnClickListener(this);
ListView view = (ListView)findViewById(R.id.files);
File[] files = Environment.getExternalStorageDirectory().listFiles();
Log.d(TAG, files.toString());
view.setAdapter(new ArrayAdapter<File>(this, R.layout.file_row, files));
layout.files
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:id="@+id/local_instructions" android:text="@string/local_instructions"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" />
<ListView android:id="@+id/files" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@id/local_instructions"
android:background="#ffffff" />
<Button android:id="@+id/folder_use" android:text="@string/folder_use" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1" android:layout_alignParentBottom="true" />
</RelativeLayout>
layout.file_row
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent" />
我失去了一些東西明顯?
感謝