java - ListView 不在较小的屏幕上显示项目

标签 java android xml layout screen-size

我有一个屏幕更大的模拟器,一切运行良好。 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/

相关文章:

java - 用java计算LRC

java - 使用 JanusGraph Java API 和 HBase 时出现 TemporaryBackendException

android - 如何以编程方式将多个自定义 linearLayouts 添加到 listView 项目

java - 在 Javadocs 中,我应该如何在 <code> 标签中编写复数形式的单数对象?

带有 webview UI 的 Java 桌面应用程序

java - 无法使用 apktool : "Asset package include not found" 编译应用程序

android - Android 4.0 模拟器上的 Google Play

xml - PowerShell 在读取大型 (50 MB) XML 文档时抛出 System.OutOfMemoryException

java - 如何在 Java 中构建读取 xml 文件的构造函数?

python-3.x - 操作系统错误 : [Errno 22] Invalid argument Getting invalid argument while parsing xml in python