由网友(心上的旧疤べ)分享简介:我测试内置的web视图中的Android应用程序。我的问题是下面的code 的WebView web视图=(web视图)findViewById(R.id.webView1);webView.loadUrl(http://google.com);触发意图(sugesting的安装的浏览器打开网络)而不是打开它在内...
我测试内置的web视图中的Android应用程序。我的问题是下面的code
的WebView web视图=(web视图)findViewById(R.id.webView1);
webView.loadUrl(http://google.com);
触发意图(sugesting的安装的浏览器打开网络)而不是打开它在内置的web视图。我应该怎么做,以避免呢?
解决方案 的WebView mWebView =(web视图)findViewById(R.id.webView1);
mWebView.setWebViewClient(新WebViewClient(){
@覆盖
公共无效onReceivedError(web视图来看,INT错误code,
字符串描述,字符串failingUrl){
//处理错误
}
@覆盖
公共布尔shouldOverrideUrlLoading(web视图查看,字符串URL){
view.loadUrl(URL);
返回true;
}
});
mWebView.loadUrl(http://google.com);
这将不会打开其他broweser。有参考这里开发者的网站。
I'm testing the built-in WebView in the Android apps. My problem is that the following code
WebView webView = (WebView) findViewById(R.id.webView1);
webView.loadUrl("http://google.com");
triggers an intent (sugesting the installed browsers for opening the web) instead of open it in the built-in WebView. What should I do for avoiding that?
解决方案WebView mWebView= (WebView) findViewById(R.id.webView1);
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
// Handle the error
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
mWebView.loadUrl("http://google.com");
This won't open other broweser. Have reference here from DEVELOPER's SITE.
相关推荐
最新文章