android - Cancel swipe navigaton -
i'm trying cancel card swipe in glass if card has not been processed. have special indicator checked in swipe_right
gesturedetector.setbaselistener(new gesturedetector.baselistener() { @override public boolean ongesture(gesture gesture) { if (gesture == gesture.tap) { openoptionsmenu(); return true; } else if (gesture == gesture.two_tap) { runspeechrecognition(); return true; } else if (gesture == gesture.swipe_right) { // on right (forward) swipe checkcards checkcard = mcheckcardsinfo.get(cardposition); if (checkcard.getstatus() == 1){ return true; }else{ return false; } } else if (gesture == gesture.swipe_left) { // on left (backwards) swipe return true; } else if (gesture == gesture.swipe_down) { finish(); } return false; } });
i thought returning false enought (i chcked in debugger , it's called), card changend. tried find method, unsuccessfully. maybe missed something.
you're error simple! say, "i thought returning false enough" - if understand correctly, want cancel swipe navigation. basically, stop swipe navigation occurring.
you have backwards. google developers page on gesturedetector
s:
public boolean onmotionevent (motionevent event)
added in api level xe12 processes motion event, returning true if events should consumed or if gesture detected.
returns:
reflects whether touch event consumed
the meaning of return value same of different methods. return true consume event, , false not consume event. in other words, if want 1 handle event, , not allow default actions occur on event, return true indicate consume event.
to fix problem, return true, not false!
Comments
Post a Comment