我想知道是否可以模拟doulbe tap事件。我试过了
TouchUtils.clickView(...)
连续两次,但没有奏效。我也试着用这种方式:
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
eventTime +=200;
downTime +=200;
Instrumentation instrumentation = getInstrumentation();
MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, mainview.getWidth()/2, mainview.getHeight()/2, 0);
instrumentation.sendPointerSync(event);
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, mainview.getWidth()/2, mainview.getHeight()/2, 0);
instrumentation.sendPointerSync(event);
downTime = SystemClock.uptimeMillis();
eventTime = SystemClock.uptimeMillis();
eventTime +=200;
downTime += 200;
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, mainview.getWidth()/2, mainview.getHeight()/2, 0);
instrumentation.sendPointerSync(event);
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, mainview.getWidth()/2, mainview.getHeight()/2, 0);
instrumentation.sendPointerSync(event);
但事件仍未触发。