Public class countdowntimeractivity extends activity {
Private timecount time;
Private button checking;
@ Override
Protected void oncreate (bundle savedinstancestate ){
// Todo auto-generated method stub
Super. oncreate (savedinstancestate );
Setcontentview (R. layout. Main );
Time = new timecount (60000,100 0); // construct the countdowntimer object
Checking = (button) findviewbyid (R. Id. button1 );
Checking. setonclicklistener (New onclicklistener (){
@ Override
Public void onclick (view v ){
Time. Start (); // start timing
}
});
}
/* Define an internal countdown class */
Class timecount extends countdowntimer {
Public timecount (long millisinfuture, long countdowninterval ){
Super (millisinfuture, countdowninterval); // The parameters are in sequence the total length of time and the interval between the time.
}
@ Override
Public void onfinish () {// triggered when timing is complete
Checking. settext ("re-verify ");
Checking. setclickable (true );
}
@ Override
Public void ontick (long millisuntilfinished) {// display the timing process
Checking. setclickable (false );
Checking. settext (millisuntilfinished/1000 + "seconds ");
}
}