开发者

How to retain onTouchEvent while touching screen?

I have the following method to handle when I touch the screen:

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");
    }
    retu开发者_如何学Crn touchDown;

}

The result of the Logcat when I touch the screen without removing my finger is:

touching the screen: YES
touching the screen: NO

I don't want show the second log until I release myfinger from the screen.

What I'm doing wrong?

Thanks.


You need a break; in your first (and second) case. I've been stung by that, too. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜