RSS Feed

Detecting Gestures In Android Studio

This is how to detect gestures. I cribbed the code from this very good article.. http://stackoverflow.com/questions/4139288/android-how-to-handle-right-to-left-swipe-gestures
I have simply made it tidier so that I haven’t used an inner class and called it from elsewhere, that is the only value of the code below.

below save in DrawPicture.java..

public class DrawPicture

{
                    public DrawPicture(Canvas canvas, MyView inView)
                   {

                                   // Note onTouchListner set for view
                                   // Note you need to pass the context

                                      inView.setOnTouchListener(new OnSwipeTouchListener(inView.getContext()));
                                       …. ect..
                   }

}

Now for the listener class itself.  I store this OnSwipeTouchListener.Java. You will find code in this link http://stackoverflow.com/questions/4139288/android-how-to-handle-right-to-left-swipe-gestures.

I have just changed it slightly for my own needs. No need to rewrite something that works well.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: