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.
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
You have to implement onTouchEvent and determine when the slide is actually happening. There is no built-in event for it.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With