我的webview android浏览器无法正确加载facebook页面。在本机浏览器上,它看起来像这样:
但是我的WebView
就像这样:
我无法弄清楚原因是什么,这是我的代码:
web = (WebView) findViewById(R.id.webView);
web.getSettings().setLoadWithOverviewMode(true);
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setPluginsEnabled(true);
web.getSettings().setLoadsImagesAutomatically(true);
web.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
web.getSettings().setCacheMode(WebSettings.LOAD_NORMAL);
web.getSettings().setSupportZoom(true);
web.getSettings().setBuiltInZoomControls(true);
web.setNetworkAvailable(true);
web.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView web, int progress) {
if (progress < 100
&& progressBar.getVisibility() == ProgressBar.GONE
&& isConnected) {
progressBar.setVisibility(ProgressBar.VISIBLE);
textProgress.setVisibility(ProgressBar.VISIBLE);
}
if (progress < 100
&& progressBar.getVisibility() == ProgressBar.VISIBLE
&& textProgress.getVisibility() == ProgressBar.VISIBLE) {
textProgress.setText(String.format(getResources()
.getString(R.string.browser_loading), progress));
}
if (progress >= 100) {
progressBar.setVisibility(ProgressBar.GONE);
textProgress.setVisibility(ProgressBar.GONE);
}
}
});
if (isConnected) {
web.setWebViewClient(new WebViewClient() {
public void onPageStarted(WebView view, String url, Bitmap map) {
return;
}
public boolean shouldOverrideUrlLoading(WebView view, String url) {
web.loadUrl(url);
return true;
}
public void onPageFinished(WebView view, String url) {
}
});
web.loadUrl(url);
请帮忙:)
答案 0 :(得分:0)
尝试在您的网络浏览链接中加载移动网站,即https://m.facebook.com
答案 1 :(得分:0)
查看Facebook SDK用于显示网络对话框的FBDialog,您可以从中复制所需的代码。它还会在加载页面时显示ProgressDialog
。