触摸屏时如何保留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
我不想显示第二个日志,直到我从屏幕上释放手指。
我做错了什么?
谢谢。
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");
}
return 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在第一个(和第二个)情况下,您需要一个
break;
。我也被这个刺痛过:)You need a
break;
in your first (and second) case. I've been stung by that, too. :)