Countdown timer with pause and resume

后端 未结 8 950
小蘑菇
小蘑菇 2021-01-05 04:17

I want to do countdown timer with pause and restart.Now i am displaying countdown timer By implenting ontick() and onfinish().please help me out.HEre is th code for countdow

8条回答
  •  既然无缘
    2021-01-05 04:36

    in onTick method..save the milliseconds left

       long s1=millisUntilFinished;
    

    when you want to pause the timer use..

       Counter.cancel();
    

    when you want to resume create a new countdowntimer with left milliseconds..

     timervalue=s1
      counter= new Counter1();
       counter.start();
    

    See this link

提交回复
热议问题