繁体   English   中英

ListView不滚动

[英]ListView is not scrolling

我在AbsoluteLayout中有一个listview,而不是滚动。

XML是:

<ListView
    android:id="@+id/listTrauma"
    android:layout_width="fill_parent"
    android:layout_height="178dp"
    android:layout_x="0dp"
     android:scrollbars="none"
    android:layout_y="666dp" >
</ListView>

和适配器代码:

adapter = new ArrayAdapter<String>(getApplicationContext(),
            R.layout.test1, dataTrauma);

您需要使用线性布局而不是绝对布局。 此外,编辑列表视图属性,并使用以下内容:

<ListView
android:id="@+id/listTrauma"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none"/>

嘿AbsoluteLayout已被弃用。 使用LineaLayout或RelativeLayout很好。 您可以查看信息以获取更多信息。 android:layout_height="0dp"android:layout_weight="1"将占用空间并在该列表中添加一些元素。它将滚动。

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        android:id="@+id/widget0"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        xmlns:android="http://schemas.android.com/apk/res/android">

        <ListView
           android:id="@+id/listTrauma"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:scrollbars="none"
            android:layout_weight="1">
        </ListView>

    </LinearLayout>

我想在你的情况下,你已经给你的列表一个特定的高度,我想这就是为什么它不滚动。 我希望这有帮助。

使用RelativeLayout而不是AbsoluteLayout AbsoluteLayout在API级别3中进行了deprectatedhttp//developer.android.com/reference/android/widget/AbsoluteLayout.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM