Countdown Timer required on Android

前端 未结 4 1743
粉色の甜心
粉色の甜心 2020-12-06 23:05

Here is the link where i have discussed about a countdown timer of format(mm:ss) in Java:

Java console code for StopWatch/Timer?

Now i want to display (and u

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 23:23

    You can also use the CountDownTimer class available in android.

    Just declare a constructor and start the timer with

    timer test=new timer(30000,1000);
    

    onTick will get fired once in every 1000ms in the above case. You can update your TextView from here

    class timer extends CountDownTimer
    {
    
     public timer(long millisInFuture, long countDownInterval) 
        {
      super(millisInFuture, countDownInterval);
      // TODO Auto-generated constructor stub
     }
    
     @Override
     public void onFinish() 
        {
    
    
     }
    
     @Override
     public void onTick(long millisUntilFinished) 
        {
      // TODO Auto-generated method stub
                // Update your textview on on tick
    
     }
    
     }
    

提交回复
热议问题