ProgressBar进度条.doc
文本预览下载声明
ProgressBar进度条
extends View
java.lang.Object
? android.view.View
? android.widget.ProgressBar
Known Direct Subclasses
AbsSeekBar, ContentLoadingProgressBar
Known Indirect Subclasses
AppCompatRatingBar, RatingBar, SeekBar
Class Overview
Visual indicator of progress in some operation. Displays a bar to the user representing how far the operation has progressed; the application can change the amount of progress (modifying the length of the bar) as it moves forward. There is also a secondary progress displayable on a progress bar which is useful for displaying intermediate progress, such as the buffer level during a streaming playback progress bar.
A progress bar can also be made indeterminate. In indeterminate mode, the progress bar shows a cyclic animation without an indication of progress. This mode is used by applications when the length of the task is unknown. The indeterminate progress bar can be either a spinning wheel or a horizontal bar.
The following code example shows how a progress bar can be used from a worker thread to update the user interface to notify the user of progress:
public class MyActivity extends Activity {
private static final int PROGRESS = 0x1;
private ProgressBar mProgress;
private int mProgressStatus = 0;
private Handler mHandler = new Handler();
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.gressbar_activity);
mProgress = (ProgressBar) findViewById(R.gress_bar);
// Start lengthy operation in a background thread
new Thread(new Runnable() {
public void run() {
while (mProgressStatus 100) {
mProgressStatus = doWork();
// Update the progress bar
mHandler.post(new Runnable() {
public void run() {
mProgress.setProgress(mProgressStatus);
}
});
显示全部