模拟用户点击事件
private void setSimulateClick(View view, float x, float y) {
long downTime = SystemClock.uptimeMillis();
final MotionEvent downEvent = MotionEvent.obtain(downTime, downTime,MotionEvent.ACTION_DOWN, x, y, 0);
downTime += 1000;
final MotionEvent upEvent = MotionEvent.obtain(downTime, downTime,MotionEvent.ACTION_UP, x, y, 0);
view.onTouchEvent(downEvent);view.onTouchEvent(upEvent);downEvent.recycle();
upEvent.recycle();}
标签:MotionEvent,float,点击,downEvent,downTime,android,upEvent,模拟,view
来源: https://www.cnblogs.com/lvlv/p/12539382.html