I have a gridview displaying some images. I have implemented a ViewFlipper to navigate pages of gridviews, my problem is that I can't use now the onItemClickListener.
I'm trying to use onSingleTapConfirmed instead.
This is MyGestureDetector class:
class MyGestureDetector extends SimpleOnGestureListener {
private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
System.out.println(" in onFling() :: ");
if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
return false;
if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE
&& Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
vf.setInAnimation(inFromRightAnimation());
vf.setOutAnimation(outToLeftAnimation());
vf.showNext();
} else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE
&& Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
vf.setInAnimation(inFromLeftAnimation());
vf.setOutAnimation(outToRightAnimation());
vf.showPrevious();
}
return super.onFling(e1, e2, velocityX, velocityY);
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
// TODO Auto-generated method stub
Log.e("Item Click","Item Click");
return super.onSingleTapConfirmed(e);
}
}
What I need to do now is capture which item of the gridview has been clicked using the x and y coordinates (e.getX() and e.getY()).
Someone answered here https://stackoverflow.com/a/6419223/1025506 that using pointToPosition method should work, but I don't know how to achieve that.
Thanks and sorry for my english.