widget(8、ProgressBar)

ProgressBar为进度条,在andoird中有长条形、圆形等,用以呈现事件进度。主要定义如下:

    <ProgressBar
        android:id="@+id/progressBar1"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

ProgressBar 常用的API是设置和获取进度,实例如下:

bar = (ProgressBar)findViewById(R.id.progressBar1);
bar.setMax(100);//设置进度条的最大值
bar.setProgress(50);//设置进度条1当前进度
bar.setSecondaryProgress(60);//设置进度条2当前进度
        
final Timer timer = new Timer();        
timer.schedule(new TimerTask(){

    @Override
    public void run() {
                //修改进度条
        bar.incrementProgressBy(5);
        bar.incrementSecondaryProgressBy(5);
    }
            
}, 1000, 5000);
posted @ 2013-01-24 11:20  Fredric_2013  阅读(158)  评论(0编辑  收藏  举报