I have a TableLayout with a HScroll and VScroll so I can scroll in all directions. For this scrollable layout I used: Scrollview vertical and horizontal in android . This uses a onTouchEvent.
There are items in my TableLayout with a onClickListener.
When i Scroll in the Table and touch an item with a onClickListener the scrolling is not working. When I just click on the item the onClickListener works fine. But I also want to scroll over these items when a move gesture is used.
How can I solve this conflict between onTouchEvent and onClickListener?
This is my onTouchEvent:
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if(true) {
mx = event.getX();
my = event.getY();
}
break;
case MotionEvent.ACTION_MOVE:
if(true) {
curX = event.getX();
curY = event.getY();
vScroll.scrollBy((int) (mx - curX), (int) (my - curY));
hScroll.scrollBy((int) (mx - curX), (int) (my - curY));
mx = curX;
my = curY;
}
break;
case MotionEvent.ACTION_UP:
if(true) {
curX = event.getX();
curY = event.getY();
vScroll.scrollBy((int) (mx - curX), (int) (my - curY));
hScroll.scrollBy((int) (mx - curX), (int) (my - curY));
}
break;
}
return true;
}