package com.example.progress;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
public class ProgressActivity extends Activity {
ProgressDialog myProgressDialog = null;
@Override
public void onCreate(Bundle icicle){
super.onCreate(icicle);
myProgressDialog = ProgressDialog.show(ProgressActivity.this,
"Please wait...", "few seconds.....", true);
new Thread() {
public void run() {
try{
// Do some Fake-Work
sleep(5000);
} catch (Exception e) { }
myProgressDialog.dismiss();
}
}.start();
}
};
这是我的代码......我现在想要的是进度条结束时,我想进入下一个屏幕....
即使我知道如何使用按钮进入其他屏幕..我无法实现它....
我试过了......
Intent i = new Intent(SplashActivity.this,screen2.class); startActivity(ⅰ);
添加此行代码并替换为progress.dismiss();
但它没有成功......请给我看一个源代码或任何帮助...我只是想进入其他屏幕......
我是新手......想要学习它......任何帮助都会受到赞赏......
答案 0 :(得分:1)
使用Handler非常容易......
private Handler handler=new Handler(){
@Override
public void handleMessage(Message msg)
{
Intent i = new Intent(SplashActivity.this, screen2.class);
startActivity(i);
myProgressDialog.dismiss();
}
}
和在Oncreate方法中,您需要随时向处理程序发送消息;
handler.sendEmptyMessageDelayed(0, 5000);//after 5000 millisec msg will be send