1

Androidのスワイプ、onTouchイベントにこのコードを使用しています

<ViewFlipper
        android:id="@+id/flipper"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/tabBTBar" >

        <LinearLayout
            android:id="@+id/first"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <ListView
                android:id="@+id/cat_listLV"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:divider="@color/grey"
                android:dividerHeight="1dp" >
            </ListView>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/Second"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#C0C0C0"
            android:gravity="center"
            android:orientation="vertical" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/ic_launcher" />
        </LinearLayout>
    </ViewFlipper>

このコードを実行すると、最初の LinerLayout にあるリストビューのみが表示されます。

最初の Linearlayout の代わりに を使用している場合は正常に動作します。

どうすればこれができるか教えてください。Listview を LinearLayout の両方に表示したい.. 最初と 2 番目。

4

1 に答える 1

2

このメソッドを Java ファイルに追加します。

@Override
public boolean dispatchTouchEvent(MotionEvent motionEvent) {
    super.dispatchTouchEvent(motionEvent);
    return gestureDetector.onTouchEvent(motionEvent);
}

onTouchEvent() メソッドを使用する代わりに

于 2013-03-06T09:42:49.883 に答える