How to pause / sleep thread or process in Android?

后端 未结 12 989
故里飘歌
故里飘歌 2020-11-22 05:49

I want to make a pause between two lines of code, Let me explain a bit:

-> the user clicks a button (a card in fact) and I show it by changing the background of thi

12条回答
  •  萌比男神i
    2020-11-22 06:50

    I know this is an old thread, but in the Android documentation I found a solution that worked very well for me...

    new CountDownTimer(30000, 1000) {
    
        public void onTick(long millisUntilFinished) {
            mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
        }
    
        public void onFinish() {
            mTextField.setText("done!");
        }
    }.start();
    

    https://developer.android.com/reference/android/os/CountDownTimer.html

    Hope this helps someone...

提交回复
热议问题