首页 > 解决方案 > Programmatic MotionEvents are highlighting content in my webview

问题描述

I'm using pretty standard code I found on here to programmatically trigger a click, (say for instance I want to click on a link) on my android WebView but it only highlights content at the specified x,y coordinates.

long when = SystemClock.uptimeMillis();
float pressure = 1.0f;
int action = 0;
int source = MotionEvent.ACTION_UP;
MotionEvent event = MotionEvent.obtain(when, when + 50, action, x, y, pressure, 1.0f, 0, 1.0f, 1.0f, 0, 0);
event.setSource(source);
mWebView.dispatchTouchEvent(event);

I'm very new at Android programming so I may be missing something obvious, any ideas?

标签: androidandroid-webview

解决方案


推荐阅读