首页 > 代码库 > android 计时器,倒计时

android 计时器,倒计时

自定义CountDownTimer

	/**
	 * 计时器
	 * @author Administrator
	 *
	 */
	class TimeCount extends CountDownTimer{

		public TimeCount(long millisInFuture, long countDownInterval) {
			super(millisInFuture, countDownInterval);
		}

		@Override
		public void onFinish() {
			
		}

		@Override
		public void onTick(long millisUntilFinished) {
			//计时显示
			if(millisUntilFinished/1000-1==0){

				//倒计时技术在handler中进行处理
				
			}
			
			tv_time.setText((millisUntilFinished/1000-1)+"s");//倒计时的时间显示
			
		}
		
	}


调用


	private TimeCount time;//计时器		
	time=new TimeCount(60000,1000);//开始计时
	time.start();