安卓模拟点击

 //模拟点击
    public static  void setViewonlick(View view,float X,float Y){

        long downTime= SystemClock.uptimeMillis();
        MotionEvent dowmEvent=MotionEvent.obtain(downTime,downTime,MotionEvent.ACTION_DOWN,X,Y,0);
        downTime+=1000;
        MotionEvent upEvent=MotionEvent.obtain(downTime,downTime,MotionEvent.ACTION_UP,X,Y,0);
        view.onTouchEvent(dowmEvent);
        view.onTouchEvent(upEvent);

        dowmEvent.recycle();
        upEvent.recycle();

    }

 

你可能感兴趣的:(安卓模拟点击)