[小技巧]Android 圆形progressbar的旋转的停止和启动

效果如下图所示:
[小技巧]Android 圆形progressbar的旋转的停止和启动_第1张图片
关键的代码

    public void start(View view) {
        // pBar.setIndeterminate(true);
        pBar.setIndeterminateDrawable(getResources().getDrawable(
                R.drawable.progressbar_global));
        pBar.setProgressDrawable(getResources().getDrawable(
                R.drawable.progressbar_global));
    }

    public void stop(View view) {
        pBar.setIndeterminateDrawable(getResources().getDrawable(
                R.drawable.page_loading_bar));
        pBar.setProgressDrawable(getResources().getDrawable(
                R.drawable.page_loading_bar));
    }

其中progressbar_global是一个animateDrawable,page_loading_bar是一个普通drawable。

一个用法是在加载页面中使用,加载失败让progressbar静止,加载时让progressbar转动。
还有什么其他用处请自行发挥想象。

你可能感兴趣的:(Android实用的代码)