倒计时

2018-07-23  本文已影响0人  信仰_021e

(1) xml控件:

    android:id="@+id/mTextView"

    android:layout_width="match_parent"

    android:layout_height="match_parent" />

(2)Activity:

private CountDownTimerstart;

start =new CountDownTimer(6000, 1000) {

@Override

        public void onTick(long millisUntilFinished) {

mTextView.setText("跳转" +"(" + millisUntilFinished /1000 +"秒" +")");

        }

@Override

        public void onFinish() {

startActivity(new Intent(WelcomeActivity2.this, WelcomeActivity3.class));

        }

}.start();

}

防止二次跳转

start.cancel();

上一篇下一篇

猜你喜欢

热点阅读