我有一个屏幕更大的模拟器,一切运行良好。 ListView
显示一切完全正常,因此它不在 java 代码中。我现在尝试在 3.2 屏幕上测试它,但 ListView
没有显示任何内容。我尝试使用较小的屏幕(3.2)模拟器,但它也没有显示任何内容,所以我想这与它们的布局有关。
我的listview.xml布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="150dp" >
</ListView>
</LinearLayout>
行 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="30dp" />
</LinearLayout>
最佳答案
你永远不应该为ListView设置android:layout_width和android:layout_height为wrap_content。
关于java - ListView 不在较小的屏幕上显示项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14631089/