这是一些简单的Android代码:
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
// do something
break;
case MotionEvent.ACTION_MOVE:
// do something
// how to trigger a ACTION_DOWN event here?
break;
}
我想在处理ACTION_DOWN
时触发ACTION_MOVE
事件。有可能吗?
答案 0 :(得分:7)
你可以这样试试。
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
// do something
break;
case MotionEvent.ACTION_MOVE:
// do something
// how to trigger a ACTION_DOWN event here?
event.setAction(MotionEvent.ACTION_DOWN);
onTouch(v,event);
break;
}
}