protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.initial_layout);
// progress bar
pb = (ProgressBar) findViewById(R.id.progressBar);
pb.setVisibility(View.VISIBLE);
new Thread(new Runnable() {
@Override
public void run() {
while (progressStatus < 100) {
progressStatus += 1;
pbHandler.post(new Runnable() {
@Override
public void run() {
pb.setProgress(progressStatus);
}
});
try {
Thread.sleep(70);
}catch (Exception e) {
e.printStackTrace();
}
}
if (pb.getProgress() >= 95) {
Intent i1 = new Intent(initialActivity.this,startingActivity.class);
startActivity(i1);
}
}
}).start();
}
我的目標是自動加載下一個活動,當進度條完成加載而不觸發任何其他事件,但我似乎無法做到這一點。我猜想線程有些問題,我是一個begginer。任何幫助讚賞。問題加載下一個活動
似乎沒有工作 – 2014-12-05 08:47:43