Sponser Link

CountDownTimer in android studio with example

CountDownTimer class in android software development kit is used for count down or create delay. It has two parameter millisInFuture and countDownInterval. millisInFuture is duration in millisecond and countDownInterval is number of iteration of timer.

In Refreshtextbox_timer()function, we will set background and text color of text view.

private void Refreshtextbox_timer()

{

new CountDownTimer(5000, 1000) {

     public void onTick(long millisUntilFinished) {

         

     }

     public void onFinish() {

      

      lblMessage=(TextView)findViewById(R.id.lblmsg); 

      lblMessage.setText("") ; 

      

      lblMessage.setBackgroundColor(Color.TRANSPARENT);

          lblMessage.setTextColor(Color.BLACK);

     }

  }.start();

}