RVG
RVG

Reputation: 3576

Before loading webview , Black screen has displayed

I've display the splash screen, after finish the splah time , i start the next activity. In second activity i've webview. i load html file on webview.

My problem is , after closing splashscreen, black screen has come. after that only webview show.

How to avoid this.

i've used below code to load html file on webview .

webView.loadData(getString(R.string.termsofuse_content), "text/html", "utf-8");

Upvotes: 3

Views: 2888

Answers (1)

Andro Selva
Andro Selva

Reputation: 54322

This is because WebView takes some time to load the Data and until it does that you will be seeing a Black Screen or a empty screen.

To overcome this, you can use the WebViewClient and show a ProgressDialog until the WebView loads the data completely.

  webview.setWebViewClient(new WebViewClient()

              {
                       @Override
                    public void onPageFinished(WebView view, final String url) {
                         progressdialog.dismiss();
                    }
                       @Override
                    public void onPageStarted(WebView view, String url,
                        Bitmap favicon) {
                    progressdialog.show();

                    }
              });

Upvotes: 3

Related Questions