gpt4 book ai didi

android - 在其中使用 Listview 时 ViewFlipper 不工作

转载 作者:行者123 更新时间:2023-11-29 21:47:57 28 4
gpt4 key购买 nike

我将这段代码用于 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 中的 ListView 。

当我在第一个 Linearlayout 中使用而不是时它会工作正常。

请建议我如何做到这一点。我想在第一个和第二个 LinearLayout.. 中显示 Listview。

最佳答案

将此方法添加到您的 java 文件中。

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

而不是使用 onTouchEvent() 方法

关于android - 在其中使用 Listview 时 ViewFlipper 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15243381/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com