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。

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 回答