Cooper
Cooper

Reputation: 103

Finger slide on screen method

Is there a built-in method in the sdk for eclipse for example like onClick or OnPause, but finger slide, that has OnSlideUp and down and left and right?

it will spare me alot of time if there is, so i wouldnt have to built one myself.

Thanks

Upvotes: 1

Views: 107

Answers (1)

DejanRistic
DejanRistic

Reputation: 2039

In Android you can use the GestureDetector.OnGestureListener to detect gestures, there is not a specific onSlideUp but there is a onFling and a onTouch that you can use. Just have your Activity implement the listener.

A quick onFling example method:

@Override
public boolean onFling(MotionEvent event1, MotionEvent event2, 
        float velocityX, float velocityY) {
    Log.d(DEBUG_TAG, "onFling: " + event1.toString()+event2.toString());
    return true;
}

Android Documentation link for handling gestures: https://developer.android.com/training/gestures/detector.html#detect

Upvotes: 1

Related Questions