how to show progress bar on webview?

后端 未结 5 1666
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-14 00:38

I am trying to open a webpage in my application using WebView. When I open webpage it shows me blank screen for a while and then open that page in browser insid

5条回答
  •  难免孤独
    2020-12-14 01:39

    Try this:

    getWindow().requestFeature(Window.FEATURE_PROGRESS);
    
    WebView mWebView = (WebView) findViewById(R.id.mywebview);
    
    mWebView.getSettings().setJavaScriptEnabled(true);
    
    final Activity activity = this;
    
    mWebView.setWebChromeClient(new WebChromeClient(){
    
             public void onProgressChanged(WebView view, int progress) {
                     activity.setTitle("Loading...");
                     activity.setProgress(progress * 100);
                        if(progress == 100)
                           activity.setTitle("My title");
                     }
    });
    
    mWebView.loadUrl(URL);
    

提交回复
热议问题