Title

Wednesday, 4 February 2015

how to cancel click event in onTouch method?


@Override   public boolean onTouch(View v, MotionEvent event) {   // TODO Auto-generated method stub   switch(event.getAction() & MotionEvent.ACTION_MASK) {   case MotionEvent.ACTION_DOWN:   //here is click or drag is not sure. we return false here.   break;   case MotionEvent.ACTION_MOVE:   //here after 2~3 events come. we known it's click or drag( by calculate the distance). question here: if current status is drag, how to cancel the click event?    break;   case MotionEvent.ACTION_CANCEL:   case MotionEvent.ACTION_UP:     break;   default:;   }   return false;   }    }

my target: create a button for drag on screen. setClickable(false) is not working in ACTION_MOVE. thanks for any helpful answer.

Answer

No comments:

Post a Comment