Sunday, 15 September 2013

ontouchlistener - Android: OnTouch, MotionEvent.ACTION_MOVE is not recognized? -



ontouchlistener - Android: OnTouch, MotionEvent.ACTION_MOVE is not recognized? -

here code, want observe when finger goes downwards screen when touch screen observe action_down when go downwards screen finger, action_move not recognized, neither action_up know why?

float x=0; protected void oncreate(bundle savedinstancestate) { things imageview image2 = (imageview) findviewbyid(r.id.imageview3); image2.setontouchlistener(new ontouchlistener(){ @override public boolean ontouch(view arg0, motionevent arg1) { if (arg1.getaction()==motionevent.action_down) { x=arg1.getx(); } else { if (arg1.getaction()==motionevent.action_move){ if (arg1.getx()>x) { things } } else { if (arg1.getaction()==motionevent.action_up){ things } } } }

if ontouch() method returns false in response initial action_down motionevent, not receive of subsequent events belong particular gesture. instead touch events presented parent in hierarchy.

to phrase way, if homecoming false ontouch() during start of gesture (the action_down), signals method no longer wants see more of gesture, , gesture's events should go parent view.

as markproxy points out in comments below, returning false when motionevent other action_down, such action_move example, not prevent subsequent motionevents in current gesture beingness presented view.

android ontouchlistener actionevent

No comments:

Post a Comment