Is there something like onLeftSwipeListener and onRightSwipeListener in Android? I want to switch views swiping finger back and forward. I use a FrameLayout and an ImageView ins
yourView.setOnTouchListner(onThumbTouch );
OnTouchListener onThumbTouch = new OnTouchListener() {
float previouspoint = 0 ;
float startPoint=0;
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(v.getId()) {
case R.id.tvDetailsalaujairiyat: // Give your R.id.sample ...
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
startPoint=event.getX();
System.out.println("Action down,..."+event.getX());
break;
case MotionEvent.ACTION_MOVE:
break;
case MotionEvent.ACTION_CANCEL:
previouspoint=event.getX();
if(previouspoint > startPoint){
//Right side swipe
}else{
// Left side swipe
}
break;
}
break;
}
return true;
}
};