2011-02-22 54 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