How to Countdown to a day using Android CountDownTimer

后端 未结 3 862
野的像风
野的像风 2021-02-06 19:39

I\'m new here and new to Android Development, I Have a question regarding the Android CountDownTimer. How am I able to use Android\'s CountDownTimer, to count down to a specific

3条回答
  •  -上瘾入骨i
    2021-02-06 20:08

    Date currentDate=new Date();
    Date endDate=new Date();
    long difference = endDate.getTime() - currentDate.getTime();
    new CountDownTimer(difference, 1000)     {
    
    public void onTick(long millisUntilFinished) {
    
    }
    
    public void onFinish() {
      System.out.println("Done");
     }
    }.start();
    

提交回复
热议问题