private TextView tv;
Handler handler = new Handler() {
public void handleMessage(android.os.Message msg) {
int i=(Integer) msg.obj;
if(i>0){
tv.setText(i+"后跳转");
}else{
tv.setText("时间到");
startActivity(new Intent(getApplicationContext(), Main1Activity.class));
}
};
};
private Timer timer; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
ImageView ima = (ImageView) findViewById(R.id.ima);
tv = (TextView) findViewById(R.id.time);
BitmapUtils bitmapUtils = new BitmapUtils(this);
bitmapUtils.display(ima,
"http://a0.att.hudong.com/15/08/300218769736132194086202411_950.jpg");
timer = new Timer();
timer.schedule(new TimerTask() {
int i=3;
@Override
public void run() {
Message msg = Message.obtain();
msg.obj=i;
i--;
handler.sendMessage(msg);
}
}, 1000, 1000);
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
timer.cancel();
}
Handler handler = new Handler() {
public void handleMessage(android.os.Message msg) {
int i=(Integer) msg.obj;
if(i>0){
tv.setText(i+"后跳转");
}else{
tv.setText("时间到");
startActivity(new Intent(getApplicationContext(), Main1Activity.class));
}
};
};
private Timer timer; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
ImageView ima = (ImageView) findViewById(R.id.ima);
tv = (TextView) findViewById(R.id.time);
BitmapUtils bitmapUtils = new BitmapUtils(this);
bitmapUtils.display(ima,
"http://a0.att.hudong.com/15/08/300218769736132194086202411_950.jpg");
timer = new Timer();
timer.schedule(new TimerTask() {
int i=3;
@Override
public void run() {
Message msg = Message.obtain();
msg.obj=i;
i--;
handler.sendMessage(msg);
}
}, 1000, 1000);
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
timer.cancel();
}