I have an android application. I have four screens and each screen contains a listview.. My requirement is that when a user flips horizontally then it should change the ui screen and when the user flips vertically it should scroll through the list.My code is
public boolean dispatchTouchEvent(MotionEvent event)
{
System.out.println("22");
int eventaction=event.getAction();
switch(eventaction)
{
case (MotionEvent.ACTION_MOVE):
System.out.println("move");
a=1;
break;
case MotionEvent.ACTION_UP:
System.out.println("up");
if(a==1)
{
view1.setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_left));
view1.showNext();
}
a=0;
break;
default:
break;
}
return super.dispatchTouchEvent(event);
}
I had a similar issue where the children were eating up all the scroll events. I ended up overiding the
onInterceptTouchEventin the parent to detect if it was a horizontal or vertical swipe and acting accordingly. You would want something like thiswhere you have some function that determines from your history if the new motion event constitutes a horizontal motion event.