I had implemented a custom Gallery with custom Adapter.
My Requirement is that however fast or slow does the user operates fling on the gallery only one item should change in the gallery.
I tried to override the Gallery's onFling
method
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
//Log.e("VELOCITY ORIGINAL", ""+velocityX);
if (velocityX > 500) {//moving left
velocityX = 500.0f;
}else if(velocityX < -500){//moving right
velocityX = -500.0f;
}
//Log.e("VELOCITY MODIFIED", ""+velocityX);
return super.onFling(e1, e2, velocityX, velocityY);
}
But this did not produce desired results as sometimes it would flick one item and some times it won't.
Then I tried
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
return false;
}
But this completely disabled fling operation.
What could be the solution?