tags:

views:

124

answers:

4

dear friends,

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.

+1  A: 

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

BrennaSoft
A: 

I've used onGesturePerformed callback, but you have to record the gesture pattern using the Emulator, save the pattern on the res and do something like this: Activity:

mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
if (!mLibrary.load()) {
 finish();
}           
GestureOverlayView gestures = (GestureOverlayView)   
findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);

public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
  ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
  if (predictions.size() > 0 && predictions.get(0).score > 1.0) { ... }}
Tiago Bastos
A: 

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.

Greg
could you please a bit more..
UMMA
or email me sample code? [email protected]
UMMA
@UMMA: A bit more what? Also, asking for people to reply by e-mail is rude towards the community. Any additions should be added to the post so that other people can learn as well.
Matti Virkkunen
Check this new article on Andrid blog : http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.htmlI think you should find all you need there.
Greg
A: 

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

UMMA