I am trying to scroll left and right through the list and get viewflipper in swtich. Just like the remeberthemilk app and the default news and weather app on the main page ("News Scrolling"). Using various tutorials found by ive, I came across one stackoverflow that shows how to implement swipe gestures
class MyGestureDetector extends SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
try {
if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
return true;
if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
} else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
viewFlipper.setInAnimation(slideRightIn);
viewFlipper.setOutAnimation(slideRightOut);
viewFlipper.showPrevious();
}
} catch (Exception e) {
}
return true;
}
}
And I got this job by doing
lstView.setOnTouchListener(gestureListener);
However, sometimes it happens that the listview setOnItemClickListener will be triggered when a person scrolls. How to prevent this, and only run setOnItemClickListener when the user actually clicks on the list item, and not just on it.
Thank you, Faisal Abid