2013-06-28 26 views
2

我想在我的應用程序中倒計時,並用TextView在屏幕上顯示時間。怎麼做? 我使用類CountDownTimer countDown,但如果你有其他的解決方案,請告訴我,並舉一些例子。 對不起,我的英語和Thx。在TextView Android上顯示倒計時時間

+0

我使用CountDownTimer,它對我很好。你有什麼問題? – HalR

回答

1

我想你可以使用此代碼來計算的倒計時時間,並顯示到TextView的使用HandlerpostDelayed是(此代碼計算每一秒,你可以改變它)

int time=60; //second 
final Handler handler = new Handler(); 
     Runnable r = new Runnable() { 
      public void run() { 
       time--; 
       textview.setText("Countdown time: "+time+" seconds"); 
      } 
     }; 
     handler.postDelayed(r, 1000); 
2

由於@QuocTruong回答,最好的選擇。

看看CountDownAnimation,它確實是你想要的。 Here是包含測試文件的項目。