熟悉AndroidAPI系列16—-ProgressBar

设置风格style="?android:attr/progressBarStyleSmall"

style="@android:style/Widget.ProgressBar.Horizontal"

 

android中的进度条

 

各种进度条关系

  • 上图圆圈为ProgressBar,风格为垂直
  • 上图右上为水平风格的ProgressBar
  • 上图坐下为SeekBar
  • 上图星星为RatingBar

控制进度条

  • max属性:
  • progress属性:当前进度
  • secondaryProgress属性:联想解压缩时有两个进度条,secondaryProgress属性就是次要的那个进度
  • isIndeteminate():boolean---圆圈的风格为true,其他为false
  • incrementBy(), incrementSecondaryBy()
 1  public class MyActivity extends Activity {
 2      private static final int PROGRESS = 0x1;
 3 
 4      private ProgressBar mProgress;
 5      private int mProgressStatus = 0;
 6 
 7      private Handler mHandler = new Handler();
 8 
 9      protected void onCreate(Bundle icicle) {
10          super.onCreate(icicle);
11 
12          setContentView(R.layout.progressbar_activity);
13 
14          mProgress = (ProgressBar) findViewById(R.id.progress_bar);
15 
16          // Start lengthy operation in a background thread
17          new Thread(new Runnable() {
18              public void run() {
19                  while (mProgressStatus < 100) {
20                      mProgressStatus = doWork();
21 
22                      // Update the progress bar
23                      mHandler.post(new Runnable() {
24                          public void run() {
25                              mProgress.setProgress(mProgressStatus);
26                          }
27                      });
28                  }
29              }
30          }).start();
31      }
32  }

 

posted @ 2015-01-24 20:37  lya_nju  阅读(273)  评论(0编辑  收藏  举报