在listview中使用viewflipper,
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;
// right to left swipe
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) {
// nothing
}
return true;
}
}
lstView.setOnTouchListener(gestureListener);
然后呢就会和setOnItemClickListener这个冲突,你本来想进行viewFlipper转换的时候却触发了OnItemClickListener,为了解决这个问题
需要继承 @Override
public boolean onSingleTapConfirmed(MotionEvent e) {
// TODO Auto-generated method stub
Log.e("Item Click","Item Click");
return super.onSingleTapConfirmed(e);
}
在SimpleOnGestureListener中