这是我的处理程序代码,我在oncreate()方法中设置了我的进度条
progressBar = (ProgressBar) findViewById(R.id.progressBar);
thread = new Thread(new MyThread());
thread.start();
handler = new Handler() {
@Override
public void handleMessage(Message msg) {
progressBar.setProgress(msg.arg1);
}
};
if(progressBar.getProgress()==99)
{
Intent i = new Intent(SplashScreen.this,MainActivity.class);
startActivity(i);
finish();
}
这是MyThread类,通过它我向处理程序发送消息
class MyThread implements Runnable{
@Override
public void run() {
for (int i=0;i<100;i++){
Message message = Message.obtain();
message.arg1 = i;
handler.sendMessage(message);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}//mythread
我想在进度条完成进度时开始我的主要活动。 但是mesage.arg1返回null 告诉我我在哪里犯错误
This is the screen shot which andriod studio is generating to me