我有3個ListView的在我的活動,我想同時滾動它們所有在一起,所以我用Scrollview >>線性佈局>> 3列表視圖。但還是他們每個人單獨在這裏滾動 是XML代碼:Listview doesnt scroll synchrologicly
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_order_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.nir.nestleapp.OrderItemsActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="410dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="500dp"
android:orientation="horizontal">
<ListView
android:layout_width="125dp"
android:id="@+id/ItemNameList"
android:layout_height="372dp">
</ListView>
<ListView
android:id="@+id/ItemPriceList"
android:layout_width="125dp"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/QuantityList">
</ListView>
<ListView
android:id="@+id/QuantityList"
android:layout_width="125dp"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_toEndOf="@id/ItemPriceList">
</ListView>
</LinearLayout>
</ScrollView>
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:id="@+id/button3" />
</RelativeLayout>
ListView處理它自己的滾動,所以你通常不應該把它放在一個ScrollView父類中。重構代碼以使用單個ListView(使用自定義適配器合併到不同的內容),或者只使用一個線性佈局的ScrollView。 – RobCo