长条ProgressBar的实现

Feb 01, 2011

SMS Backup在现实备份进度时候的进度条是长条形的,在xml只进行的最紧绷的说明,进一步的设置都是通过java code实现的:

XML文件:

<progressbar android:id="@+id/details_sync_progress"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    style="?android:attr/progressBarStyleHorizontal"
    android:indeterminate="false"
/>

SMS Backup在java代码中关于ProgressBar的控制:

if (progressIndeterminate) {
       mProgressBarIndet.setVisibility(View.VISIBLE);
       mProgressBar.setVisibility(View.GONE);
} else {
       mProgressBar.setVisibility(View.VISIBLE);
       mProgressBarIndet.setVisibility(View.GONE);
       mProgressBar.setIndeterminate(progressIndeterminate);
       mProgressBar.setMax(progressMax);    //进度条的最大值
       mProgressBar.setProgress(progressVal);      //已经备份了的短信作为进度条初值
}

点击查看更多样式ProgressBar的实现

Get In Touch With Us ...