开发者

How to retain onTouchEvent while touching screen?

开发者 https://www.devze.com 2023-02-13 06:26 出处:网络
I have the following method to handle when I touch the screen: public boolean onTouchEvent(MotionEvent event) {

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

精彩评论

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