开发者

Can I change the progress bar in a webview to a progress circle?

This is my code :

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..."开发者_如何学JAVA);
             activity.setProgress(progress * 100);
                if(progress == 100)
                   activity.setTitle("My title");
             }
});

mWebView.loadUrl(URL);

I want to change the progress style to a circle.

How to change it?


This should do it:

getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS); // Request progress circle
setProgressBarIndeterminateVisibility(true); // Show progress circle

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)
                   setProgressBarIndeterminateVisibility(false); // Hide progress circle when page loaded
                   activity.setTitle("My title");
             }
});

mWebView.loadUrl(URL);


getWindow().setFeatureInt( Window.FEATUREPROGRESS, Window.PROGRESSVISIBILITY_ON);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜