tags:

views:

61

answers:

2

I want to check for someone placing their finger on the center of the screen and dragging to the right, how could this be accomplished?

SOLUTION: http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/

A: 

Look into the GestureDetector class

schwiz
ended up getting it done with this example: http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/
tylercomp
+1  A: 

You could implement the onTouchListener and do something like this:

public boolean onTouch(View view, MotionEvent event) {
  int currentX = event.getX();    

  if(event.getAction() == MotionEvent.ACTION_MOVE) {
    // oldX would be defined as a private property of the class (most likely an Activity)
    if(currentX > oldX) {
      // moving right

      oldX = currentX;
    } else {
      // moving left or not moving at all

      oldX = currentX;
    }
  }

  return true;
}

You can probably play around with that and make it work the way you want.

xil3