我如何可以加载Web视图在其他浏览的链接? [英] How can i load a link in other browser from web view?
本文介绍了我如何可以加载Web视图在其他浏览的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的网页加载视图的字符串值,当我在网络视图中显示应当手机的其他网络浏览器中打开链接点击我的需要。
我想这样的 - 一个String =你好更多.... www.google.com
字符串的html =< HTML和GT;<身体GT + S +< /身体GT;< / HTML>中
webview.loaddata(HTML);
I am loading string value in my web view and i need when i click on the link shown in web view should open in other web browser of phone.
I want like this - String s = "hello read more.... www.google.com"
String html = "<html><body>+s+</body></html>"
webview.loaddata(html);
推荐答案
试试这个:
webView.setWebViewClient(new WebViewClient(){
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url != null && (url.startsWith("http://") || url.startsWith("https://"))) {
view.getContext().startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
} else {
return false;
}
}
});
这篇关于我如何可以加载Web视图在其他浏览的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文