我有一些html代码,我在Webview中显示,它有一个阅读更多的链接在它的点击,它把我带到默认浏览器。但是我想改变这种行为并在不同的活动中打开该链接,为此我想检测HTML代码中该链接的点击。我尝试了下面的代码,但无济于事。检测HTML数据中的<a>标记的点击?
Inside onCreate registerForContextMenu(w);
和WebViewClient
这
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
WebView.HitTestResult result = w.getHitTestResult();
System.out.println("asdasfdf");
if (result.getType() == HitTestResult.ANCHOR_TYPE
|| result.getType() == HitTestResult.SRC_ANCHOR_TYPE) {
System.out.println("#%@#%$%");
// set the header title to the link url
}
}
http://stackoverflow.com/questions/11188348/android-html-anchor-link-works-only-once-in-webview/11205345#11205345阅读这个答案。 – MKJParekh