开发者

Android ViewFlipper + Gesture Detector

开发者 https://www.devze.com 2022-12-24 10:24 出处:网络
I am using gesture detector to catc开发者_如何学运维h \"flings\" and using a view flipper to change the screen when this happens. Some of my child views contain list views. The the gesture detector wo

I am using gesture detector to catc开发者_如何学运维h "flings" and using a view flipper to change the screen when this happens. Some of my child views contain list views. The the gesture detector wont recognize a swipe if you swipe on the list view. But it will recognize it if it is onTop of TextView's or ImageView's. Is there a way to implement it so that it will recognize the swipes even if they are on top of another view that has a ClickListener?


Thank you for your answer. In order to get it working how I wanted it to all I had to add was this:

myList.setOnTouchListener(gestureListener);

for each of my lists. Now they correctly recognize horizontal swipes to change views, and vertical movement for scrolling the list.


An example from here: http://android-developers.blogspot.com/2009/10/gestures-on-android-16.html

<android.gesture.GestureOverlayView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/gestures"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"    
    android:gestureStrokeType="multiple"
    android:eventsInterceptionEnabled="true"
    android:orientation="vertical">
<ListView
    android:id="@android:id/list"  
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"  />
</android.gesture.GestureOverlayView>

I used this tutorial to look at Android's gesture overlay view. The example which this comes from has a ListView utilizing this GestureOverlayView to scroll the list.


There is another wonderful solution at android-journey.blogspot

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号