android容易倒计时

android简单倒计时public class TimerActivity extends Activity {/** Called when the activity is first

android简单倒计时

public class TimerActivity extends Activity {/** Called when the activity is first created. */private TextView timerView ;private MyTimer timer;@Overridepublic 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() {@Overridepublic void onClick(View v) {timer.start();}});}class MyTimer extends CountDownTimer {public MyTimer(long millisInFuture, long countDownInterval) {super(millisInFuture, countDownInterval);}@Overridepublic void onFinish() {timerView.setText("结束了...");}@Overridepublic void onTick(long millisUntilFinished) {Log.i("millisUntilFinished:", String.valueOf(millisUntilFinished));timerView.setText(""+millisUntilFinished/1000);}}}