iT邦幫忙

0

[筆記]為WebView增加讀取動畫

  • 分享至 

  • xImage
  •  

第一步:MainActivity.java
1.import

import android.app.ProgressDialog;
import android.webkit.WebViewClient;
protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);

在這之後加入

mProgressDialog = new ProgressDialog(this);
                web_view.setWebViewClient(new WebViewClient(){
                        @Override
                        public boolean shouldOverrideUrlLoading(WebView view, String url) {
                                web_view.loadUrl(url);
                                return true;
                        }
                        @Override
                        public void onPageStarted(WebView view, String url, Bitmap favicon) {
                                super.onPageStarted(view, url, favicon);
                                mProgressDialog.setMessage("努力讀取中...");
                                mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                                mProgressDialog.show();
                        }
                        @Override
                        public void onPageFinished(WebView view, String url) {
                                super.onPageFinished(view, url);
                                mProgressDialog.hide();
                        }
                        @Override
                        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                                super.onReceivedError(view, errorCode, description, failingUrl);
                                web_view.loadUrl("file:///android_asset/error.html");
                        }

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言