[英]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中進行了deprectated
: http : //developer.android.com/reference/android/widget/AbsoluteLayout.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.