Android 實現簡單 倒計時60秒,一次1秒


 

倒計時功能如上圖所示,其實就幾行代碼即可實現效果啦!!!

 

 1             /** 倒計時60秒,一次1秒 */
 2             CountDownTimer timer = new CountDownTimer(60*1000, 1000) {
 3                 @Override
 4                 public void onTick(long millisUntilFinished) {
 5                     // TODO Auto-generated method stub
 6                     textView_time_shengxu.setText("還剩"+millisUntilFinished/1000+"秒");
 7                 }
 8 
 9                 @Override
10                 public void onFinish() {
11                     textView_time_shengxu.setText("時間已到,請重新獲取驗證碼!!!");
12                 }
13             }.start();

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM