Getting a simple fling gesture
So this is half a how-to and half a best practices question.
First, if I just want to get a simple "fling right" (which will go back to a previous activity) should I implement OnGestureListener or do something with GestureOverlayView?
I read Fling gesture detection on grid layout and it looks like if I go with OnGestureListener I'll have to manually add the listener to all my views. This is annoying, plus I'd like to add this functionality to many activities, so i'd be nice if i could fit all the logic in a self contained function. So maybe GestureOverlayView would be preferable? But all the examples I see for it are really complicated... I don't want to make my own gestures. I just want a simple swipe/fling detect as in Fling gesture detection on grid layout.
Secondly, if you advocate either position, can you post a simple example? Fling gesture detection on grid layout is for extending SimpleOnGestureListener not implementing OnGestureListener and I'm a little stuck on the steps for actually setting the gesture listener to listen to views. As for GestureOverlayView, like i said, all I've seen are complicated examples of creating your own gestures.
Presuming you've had the chance of going through the example at Code Shogun: In onFling(), you could call finish() Activity in place of ViewFlipper method calls. http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/
So, call finish() Activity instead of
viewFlipper.setInAnimation(slideLeftIn);
viewFlipper.setOutAnimation(slideLeftOut);
viewFlipper.showNext();
Hope that helps.
链接地址: http://www.djcxy.com/p/16208.html上一篇: Android Canvas上无法检测onFling和onSCroll方法?
下一篇: 获得一个简单的扔手势