安卓实现倒计时,下面的例子是10秒的倒计时


public class PowerOff extends Activity {

	TextView textView;
	CountDownTimer timer;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.power_off);

		textView = (TextView) findViewById(R.id.time);

		 timer = new CountDownTimer(10 * 1000, 1000) {

			@Override
			public void onTick(long millisUntilFinished) {
				textView.setText(millisUntilFinished / 1000 + "秒后关机");
			}

			@Override
			public void onFinish() {
				textView.setText("正在关机...");				 
			}
		}.start();
	}
}