2011-02-22 69 views
0

我有以下的方法来处理,当我触摸屏幕:如何在触摸屏时保留onTouchEvent?

public boolean onTouchEvent(MotionEvent event) { 

    boolean touchDown = true; 
    switch (event.getAction()) { 
     case MotionEvent.ACTION_DOWN: 
      Log.i(TAG,"touching the screen: YES"); 
     case MotionEvent.ACTION_UP: 
      touchDown = false; 
      Log.i(TAG,"touching the screen: NO"); 
    } 
    return touchDown; 

} 

的logcat的结果,当我触摸屏幕而不删除我的手指是:

touching the screen: YES 
touching the screen: NO 

我不想显示第二个日志,直到我从屏幕释放myfinger。

我在做什么错了?

谢谢。

回答

5

您的第一个(和第二个)案例需要一个break;。我也被这样刺痛了。 :)

+0

哦,我不知道我怎么能忘记这一点。它反弹!非常感谢你 – karse23 2011-02-22 20:46:22