2010-09-10 40 views

回答

0

查找到GestureDetector

+0

最終完成了這個例子:http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/ – tylercomp 2010-09-10 18:05:25

1

您可以實現的onTouchListener,做這樣的事情:

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; 
} 

你或許可以玩弄這一點,使它發揮作用你想要的方式。

相關問題