当前位置: 代码迷 >> Android >> android容易倒计时
  详细解决方案

android容易倒计时

热度:81   发布时间:2016-05-01 19:28:01.0
android简单倒计时
public class TimerActivity extends Activity {	/** Called when the activity is first created. */		private TextView timerView ;	private MyTimer timer;		@Override	public void onCreate(Bundle savedInstanceState) {		super.onCreate(savedInstanceState);		setContentView(R.layout.main);		timerView = (TextView)findViewById(R.id.time);		timer = new MyTimer(50000, 1000);		final Button timerButton = (Button)findViewById(R.id.start_button);		timerButton.setOnClickListener(new View.OnClickListener() {						@Override			public void onClick(View v) {				timer.start();			}		});			}	class MyTimer extends CountDownTimer {		public MyTimer(long millisInFuture, long countDownInterval) {			super(millisInFuture, countDownInterval);		}		@Override		public void onFinish() {			timerView.setText("结束了...");		}		@Override		public void onTick(long millisUntilFinished) {			Log.i("millisUntilFinished:", String.valueOf(millisUntilFinished));			timerView.setText(""+millisUntilFinished/1000);		}	}}
  相关解决方案