private TextView textView; private final Handler handler =new Handler(){ public void handleMessage(android.os.Message msg) { if(msg.what== 0){ //倒计时完毕进行跳转 Intent intent =new Intent(MainActivity.this, MyActivity.class); startActivity(intent); MainActivity.this.finish(); } textView.setText(null); }; }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //获取资源ID textView = (TextView) findViewById(R.id.hand); //创建一个线程 new Thread(){ public void run() { try { for (int i = 1; i >0; i--) { sleep(3000); i--; handler.sendEmptyMessage(i); } } catch (Exception e) { e.printStackTrace(); } }; }.start(); }
两个Activity加耗时操作跳转
最新推荐文章于 2021-05-25 19:36:49 发布