我正在努力让 ListView 能够滚动。据我所知,在 LinearLayout 中有一个 ListView 应该没问题,那为什么它不滚动呢?
这是布局
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ListView
android:id="@+id/listView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
<include layout="@layout/tab3" />
<include layout="@layout/tab1" />
</FrameLayout>
这是我用东西填满它的地方..
File folder = new File(Environment.getExternalStorageDirectory().getPath()+"/Download/");
File[] listOfFiles = folder.listFiles();
ArrayAdapter<String> arrayadp = new ArrayAdapter<String>(this, R.layout.list_files);
for (File file : listOfFiles) {
if (file.isFile()) {
String extension = "";
String filename = file.getName();
int i = filename.lastIndexOf('.');
if (i > 0) {
extension = filename.substring(i+1);
}
if(extension.equalsIgnoreCase("wav")){
arrayadp.add(filename);
}
}
}
ListView listView = (ListView) findViewById(R.id.listView1);
listView.setAdapter(arrayadp);