
倒計時功能如上圖所示,其實就幾行代碼即可實現效果啦!!!
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();
