当前位置: 代码迷 >> Android >> android 记时类
  详细解决方案

android 记时类

热度:103   发布时间:2016-04-28 02:27:06.0
android 倒计时类
public class CountdownTimerActivity extends Activity {private TimeCount time;private Button checking;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.main);time = new TimeCount(60000, 1000);//构造CountDownTimer对象time.start();checking = (Button) findViewById(R.id.button1);checking.setOnClickListener(this);}class TimeCount extends CountDownTimer {public TimeCount(long millisInFuture, long countDownInterval) {super(millisInFuture, countDownInterval);//参数依次为总时长,和计时的时间间隔}@Overridepublic void onFinish() {//计时完毕时触发checking.setText("重新验证");checking.setClickable(true);}@Overridepublic void onTick(long millisUntilFinished){//计时过程显示checking.setClickable(false);checking.setText(millisUntilFinished /1000+"秒");}}

  

  相关解决方案