Android - WebView 禁用导航到其他页面 [英] Android - WebView disable navigation to other page
本文介绍了Android - WebView 禁用导航到其他页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在单击 WebView 页面内的链接或按钮时阻止导航到另一个页面(我不想禁用触摸侦听器).
How to prevent navigation to another page when click on a link or button inside a WebView page, (I do not want to disable touch listener).
推荐答案
尝试将 new WebViewClient()
设置为 webview 并在 shouldOverrideUrlLoading(WebView view, String url) 中捕获链接代码>方法像这样
Try to set new WebViewClient()
into webview and catch link in shouldOverrideUrlLoading(WebView view, String url)
method
Like this
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.contains(youUrl)){
//do something
}
return true;
}
这篇关于Android - WebView 禁用导航到其他页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文