我与MotionEvent.ACTION_UP有一个问题,在我举起手指之前,事件被调用了。
这是我正在使用的代码。我应该改变什么?谢谢你的帮助!
public boolean onTouchEvent(MotionEvent e) {
switch(e.getAction()) {
case MotionEvent.ACTION_DOWN:
if(checkColide(e.getX(), e.getY())) {
isFootballTouched = true;
downT = c.MILLISECOND;
downX = e.getX();
}
break;
case MotionEvent.ACTION_MOVE:
//moveFootball(e.getX(), e.getY());
break;
case MotionEvent.ACTION_UP:
upT = c.MILLISECOND;
upX = e.getX();
getVelocity();
break;
}
return false;
}发布于 2012-09-17 03:45:19
如果发生这3种情况之一,请尝试返回true
public boolean onTouchEvent(MotionEvent e) {
switch(e.getAction()) {
case MotionEvent.ACTION_DOWN:
if(checkColide(e.getX(), e.getY())) {
isFootballTouched = true;
downT = c.MILLISECOND;
downX = e.getX();
}
return true;
case MotionEvent.ACTION_MOVE:
//moveFootball(e.getX(), e.getY());
return true;
case MotionEvent.ACTION_UP:
upT = c.MILLISECOND;
upX = e.getX();
getVelocity();
return true;
}
return false; }
发布于 2012-09-17 03:45:46
也许您应该从onTouchEvent()返回true。返回false意味着您对接收此View的事件不再感兴趣。希望这能有所帮助。
https://stackoverflow.com/questions/12450109
复制相似问题