<pre name="code" class="java">Chronometer chronometer;
int miss = 0;
chronometer.start();
chronometer.setOnChronometerTickListener(new OnChronometerTickListener() {
@Override
public void onChronometerTick(Chronometer ch) {
miss++;
ch.setText(FormatMiss(miss));
}
});
// 将秒转化成小时分钟秒
public String FormatMiss(int miss){
String hh=miss/3600>9?miss/3600+"":"0"+miss/3600;
String mm=(miss % 3600)/60>9?(miss % 3600)/60+"":"0"+(miss % 3600)/60;
String ss=(miss % 3600) % 60>9?(miss % 3600) % 60+"":"0"+(miss % 3600) % 60;
return hh+":"+mm+":"+ss;
}
百度知道:Android Chronometer实现时分秒的显示