禁用一个的WebView安卓点击链接或按钮 [英] Disable click link or button in a webview Android
本文介绍了禁用一个的WebView安卓点击链接或按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个web视图加载网址http://www.google.com..我想禁用事件,当我们点击该webview..I链接或按钮设置可点击=假,而不是工作..
I have a webview load URL "http://www.google.com"..I want disable event when we click link or button in that webview..I set clickable="false" but not work..
推荐答案
创建一个自定义的 WebViewClient
并覆盖 shouldOverrideUrlLoading
&放大器; shouldOverrideKeyEvent
。例如:
Create a custom WebViewClient
and override shouldOverrideUrlLoading
& shouldOverrideKeyEvent
. For example:
public class MyWebViewClient extends WebViewClient {
public boolean shuldOverrideKeyEvent (WebView view, KeyEvent event) {
// Do something with the event here
return true;
}
public boolean shouldOverrideUrlLoading (WebView view, String url) {
if (Uri.parse(url).getHost().equals("www.google.com")) {
// This is my web site, so do not override; let my WebView load the page
return false;
}
// reject anything other
return true;
}
}
这篇关于禁用一个的WebView安卓点击链接或按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文