Commonly used progress bar function, there are two kinds of progress bars:
Progressive and circular:
The basic usage code is as follows:
public void startProgress(View view) {
Runnable runnable = new Runnable() {
@Override
public void run() {
for (int i = 0; i <= 10; i++) {
final int value = i;
doWork();
progress.post(new Runnable() {
@Override
public void run() {
text.setText("更新中...");
progress.setProgress(value);
}
});
}
}
};
new Thread(runnable).start();
}
private void doWork() {
SystemClock.sleep(5000);
}