Android Studio:创建一个进度条,将在 100% 时到达下一个 activity
Android Studio: Creating a progress bar that will lead to next activity at 100%
如何创建一个进度条,让应用程序在完成后从一个 activity 跳到下一个? (条形填充至 100%)
从 Android 开发者网站,我检索到以下示例代码,但我不确定 where/how 它是否使应用程序转到下一个屏幕:
public class 我的Activity 扩展 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.layout.progressbar_activity);
mProgress = (ProgressBar) findViewById(R.id.progress_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);
}
});
}
}
}).start();
}
}
在您发布的代码中,您应该执行检查以查看 mProgressStatus
何时为 100%,然后从当前 Acrivity 开始 Intent
到您想要的 activity .
如何创建一个进度条,让应用程序在完成后从一个 activity 跳到下一个? (条形填充至 100%)
从 Android 开发者网站,我检索到以下示例代码,但我不确定 where/how 它是否使应用程序转到下一个屏幕:
public class 我的Activity 扩展 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.layout.progressbar_activity);
mProgress = (ProgressBar) findViewById(R.id.progress_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);
}
});
}
}
}).start();
}
}
在您发布的代码中,您应该执行检查以查看 mProgressStatus
何时为 100%,然后从当前 Acrivity 开始 Intent
到您想要的 activity .