为什么网址无法通过WebView加载到我的应用程序中 [英] Why Url in not loading in my application with WebView
本文介绍了为什么网址无法通过WebView加载到我的应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么我在下面的代码中写道,该网址在默认浏览器中打开,为什么未在我的应用程序中加载该网址.
whey i wrote below code, the url is opening in the default browser, why its not loading in the my app.
setContentView(R.layout.activity_main);
myWebView = (WebView) findViewById(R.id.webView);
myWebView.loadUrl("http://www.google.com");
推荐答案
尝试在WebView
上设置WebViewClient
:
myWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
myWebView.loadUrl("http://www.google.com");
这篇关于为什么网址无法通过WebView加载到我的应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文