当我的webView加载this页面时,它只是空白页面或白页我触摸屏幕内容只能显示
private WebView webview;
private ProgressDialog mProgressDialog;
private Context mContext;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
mContext = this;
webview = (WebView)findViewById(R.id.myWebView);
String url = (String)getIntent().getExtras().get("url");
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new MyWebViewClient());
if(url!=null){
webview.loadUrl(url);
}
}
class MyWebViewClient extends WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
mProgressDialog = ProgressDialog.show(mContext, "tips", "wate···the view is loading", true, false);
}
@Override
public void onPageFinished(WebView view, String url) {
mProgressDialog.dismiss();
super.onPageFinished(view, url);
}
}
答案 0 :(得分:0)
我猜网址存在问题。 我尝试使用其他网址进行360度全景视图并且有效。 检查一下:360 degree view
答案 1 :(得分:0)
以下对我来说很好。试试吧。
public class YourHtmlClass extends Activity {
private WebView mWebview;
private ProgressDialog progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.your_layout_containing_webview);
mWebview = (WebView) findViewById(R.id.webView1);
WebSettings settings = mWebview.getSettings();
settings.setJavaScriptEnabled(true);
mWebview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
progressBar = ProgressDialog.show(AboutUsHtml.this, "", "Loading...",
true);
mWebview.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
public void onPageFinished(WebView view, String url) {
if (progressBar.isShowing()) {
progressBar.dismiss();
}
}
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
AlertDialog alert = new AlertDialog.Builder(AboutUsHtml.this)
.create();
alert.setTitle("No connection"));
alert.setIcon(R.drawable.ic_launcher);
alert.setCancelable(false);
alert.setMessage("No connection"));
alert.setButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alert.show();
}
});
mWebview.loadUrl("Your URL Goes Here");
}
}