我需要创建一个可以在屏幕上拖动的Button
。我已经尝试通过在ACTION_MOVE中调用clickable
来将setClickable(false)
设置为false,但这不起作用。感谢您提供任何有用的答案。
这是我的onTouch()
方法:
@Override
public boolean onTouch(View v, MotionEvent event) {
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;
}