【发布时间】:2012-11-20 13:01:00
【问题描述】:
我的触摸监听器出现问题,实际上无法正常工作。
@Override
public boolean onTouchEvent(MotionEvent event) {
touchControll.processTouchEvent(event); //should do everything!
invalidate();
return true;
}
Methode 的 processTouchevent 只是将事件监视放在它所在的位置并处理它。 因此,如果触摸在手柄内部,它会处理手柄“动作”。但是如果我现在想处理一个 hitButton 事件,它不会做出反应。
例子
public void processHitButtonTouch(MotionEvent event){
int touchPosX = (int) event.getX();
int touchPosY = (int) event.getY();
if(event.getAction() == MotionEvent.ACTION_DOWN)
if(touchPosX > Config.BLOCKSIZE*37 && touchPosY > Config.BLOCKSIZE*3 && touchPosY < Config.BLOCKSIZE*7){
this.hitButton.buttonStatus = Pressed.PRESSED;
}
}
在每个 MotionEvent.ACTION_UP 上,我都会像这样重置整个内容:
if(event.getAction() == MotionEvent.ACTION_UP){
joyPad.status = Status.IDLE;
charac.setStatus(Status.IDLE);
this.hitButton.buttonStatus = Pressed.UNPRESSED;
}
如果它确实使用 Loggincat 处理了 1 个以上的事件并且它确实处理了(记录了 2 次触摸 2 次 downevent!),那么我并列。但它根本不像我在这里做的那样工作。 我做错了什么?!
非常感谢您的帮助!
【问题讨论】:
标签: android event-handling touch