我想在 Android 中实现两指长按。我试图覆盖 onLongPress:
private static final int LONGTIMEOUT = ViewConfiguration.getLongPressTimeout() + 100;
@Override public void onLongPress(final MotionEvent e) {
Log.i(TAG, "onLongPress");
switch (e.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
Log.i(TAG, "onLongPress:ACTION_DOWN");
break;
case MotionEvent.ACTION_POINTER_DOWN:
Log.i(TAG, "onLongPress:ACTION_POINTER_DOWN");
if (SystemClock.uptimeMillis() - e.getEventTime() > LONGTIMEOUT)
Log.i(TAG, "YES YES YES");
break;
default:
break;
}
}
但当我用两根手指在屏幕上长按时,它永远不会进入 ACTION_POINTER_DOWN 。有人知道如何正确解决/实施它吗?