1

这里是来自 ABS 示例进度条的代码,它根据 web 加载使用 进行更新ActionBar ProgressBar,事情是进度条在页面加载之前完成。任何人都可以帮助更正此代码吗?

private int mProgress = 100;
private Handler mHandler = new Handler();
private Runnable mProgressRunner = new Runnable() {
    @Override
    public void run() {
        mProgress += 1;

        //Normalize our progress along the progress bar's scale
        int progress = (Window.PROGRESS_END - Window.PROGRESS_START) / 100 * mProgress;
        setSupportProgress(progress);

        if (mProgress < 100) {
            mHandler.postDelayed(mProgressRunner, 50);
        }
    }
};

mWebView.setWebChromeClient(new WebChromeClient() {
    @Override
    public void onProgressChanged(WebView view, int progress) {
        if (mProgress == 100) {
            mProgress = 1;
            setSupportProgressBarIndeterminateVisibility(false);
            mProgressRunner.run();
        } else {
            setSupportProgressBarIndeterminateVisibility(true);
        }
    }
});
4

0 回答 0