开发者

Getting a simple fling gesture

开发者 https://www.devze.com 2023-03-09 15:32 出处:网络
So this is half a how-to and half a best practices question. First, if I just want to get a simp开发者_Python百科le \"fling right\" (which will go back to a previous activity) should I implement OnGe

So this is half a how-to and half a best practices question.

First, if I just want to get a simp开发者_Python百科le "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.

0

精彩评论

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

关注公众号