0

画面に触れたときに処理する方法は次のとおりです。

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を離すまで、2番目のログを表示したくありません。

私が間違っているのは何ですか?

ありがとう。

4

1 に答える 1

5

break;最初の(および2番目の)ケースではが必要です。私もそれに悩まされてきました。:)

于 2011-02-22T20:22:25.467 に答える