Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

which event is used to slide finger left and right ward in android?

Tags:

android

i am creating image gallery if i click on grid view of images it shows full screen image.

now i want to implement functionality of touch screen or finger sliding left and right ward to change images.

any one guide me which event should i use or whats the procedure

any help would be appriciated.

like image 799
UMAR-MOBITSOLUTIONS Avatar asked Jun 09 '10 12:06

UMAR-MOBITSOLUTIONS


3 Answers

using this example we can detect gestures of moving finger left , right , up and downward

http://android-journey.blogspot.com/2010/01/android-gestures.html

like image 62
UMAR-MOBITSOLUTIONS Avatar answered Sep 20 '22 18:09

UMAR-MOBITSOLUTIONS


You have to implement onTouchEvent and determine when the slide is actually happening. There is no built-in event for it.

like image 32
Robby Pond Avatar answered Sep 18 '22 18:09

Robby Pond


I implemented this behavior in my application JustPictures, for the exact same purpose. I did it via onTouchEvent(MotionEvent event) :

if(event.getAction()==MotionEvent.ACTION_MOVE){...}

You can get the X position of the finger with event.getX(), and compute the offset from the last time you received the event. You can then update an offset variable that is private to your view, and postInvalidate(). Then your onDraw method takes care of translating the canvas by the current offset.

like image 26
Greg Avatar answered Sep 21 '22 18:09

Greg