1

I´ve searched in all topics but i've not found anything that works for me.

I have an android application with a webview. I set up the page with a small javascript code in OnPageFinished and i see how it hides and shows elements, but i don´t want to see that. I would want that webview shows the current page while it is loading and when it's loaded fully, webview shows the new page.

Is there any way to get it?? Sorry for my english. Thanks.

rescatero
  • 11
  • 1
  • 2
  • show `ProgressDialog` till you don't get your finished `URL` – Anshul Tyagi Feb 27 '17 at 08:11
  • I show a ProgressDialog, but i see how it's doing the changes in background – rescatero Feb 27 '17 at 08:20
  • you don't wanna show processing behind of `ProgressDialog` then make it invisible for that time – Anshul Tyagi Feb 27 '17 at 08:21
  • So you injecting some javascript code in `onPageFinished()` that hides some of UI element on the page. And you don't want to display that page until script finish hiding those elements ? Right? – j2ko Feb 27 '17 at 21:23
  • @j2ko yes, i want to do that. How can i get it? – rescatero Mar 03 '17 at 07:22
  • 1
    Check my answer to this thread. Its about css but the technic could also suite your need with slight modification. http://stackoverflow.com/q/42471990/2751535 – j2ko Mar 03 '17 at 07:28

1 Answers1

1

Show progress bar or progress dialog ,initialize a progress bar on your xml page and use it to load untill the your webpage has fullyloaded

 webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebChromeClient(new WebChromeClient());
        webView.getSettings().setDomStorageEnabled(true);
        webView.post(new Runnable() {
            @Override
            public void run() {
               webView.loadUrl("file:///android_asset/Guage.html");
            }
        });

    webView.setWebViewClient(new myWebClient());


 public class myWebClient extends WebViewClient
    {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            // TODO Auto-generated method stub
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // TODO Auto-generated method stub
            progressBar.setVisibility(View.VISIBLE);
            view.loadUrl(url);
            return true;

        }

        @Override
        public void onPageFinished(WebView view, String url) {
            // TODO Auto-generated method stub
            super.onPageFinished(view, url);

            progressBar.setVisibility(View.GONE);
        }
    }
  • 1
    I only inject a javascript code in onPageFinished and i don't want to display webview rendering while it loads, without hide it, like a android native app. – rescatero Mar 03 '17 at 07:44