private TextView tv;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 1:
tv.setText("我在学习Android");
handler.sendEmptyMessageDelayed(2, 2000);
break;
case 2:
Intent intent = new Intent(MainActivity.this, ZhuActivity.class);
startActivity(intent);
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
initData();
}
private void initData() {
handler.sendEmptyMessageDelayed(1, 2000);
}
private void initView() {
tv = (TextView) findViewById(R.id.tv);
}