简体   繁体   中英

can't return motionEvent.action_up

please see my code

public boolean onTouchEvent(MotionEvent event) {
         Log.e("mainClass",""+ event.getY( ));
     manager.setNewX((int)event.getX());
     manager.setNewY((int)event.getY());
     log("action = "+event.getAction());
     manager.doTouchEvent(event.getAction());
     return false;

}

when i pressed on field - i see coordinates and action ( event.getAction() ). I see what log returned me 0 ( action.down ). But when i leave my finger from screen i not see event.action_up . Can any one explain me why i can't get actio_up

ps doTouchEvent - function which used in other class. doTouchEvent(int event);

p.s2 hello everyone:) can't set this to first line

Just return true. do not return false .

After I insert return super.onTouchEvent(event); at the end of the method (onTouchEvent must return a value) your code works for me, when I put it in a blank main activity.

You should probably return true instead of breaking in those cases because you are responding to the event. Android ACTION_UP even never called

If you define onTouchEvent() for your custom view try calling it for the super view.

return super.onTouchEvent(event);.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM