#2
yujunting2014-04-03 08:56
|
private long mNext1;//计算下一秒
private int second1 =0;//计时秒数个位
private int second2 =0;//计时秒数十位
private int minute1 =0;//计时分数个位
private int minute2 =0;//计时分数十位
//计时
private void drawTime(Canvas canvas){
long current =System.currentTimeMillis();
if(current>=mNext1){
mNext1=current+1000;
second1++;
if(second1>9){
second1-=10;//秒数的个位
}
if(second1==0){
second2+=1;
if(second2>5){
second2-=6;//秒数的十位
if(second2==0){
minute1+=1;
if(minute1>9){
minute1-=10;//分数的个位
if(minute1==0){
minute2+=1;//分数的十位
}
}
}
}
}
}
mPaint.setStrokeWidth(1);
mPaint.setTextSize(30);
mPaint.setColor(0xFFFFFF00);
canvas.drawText((minute2+""+minute1+""+" : "+second2+""+second1+""), 370, 60, mPaint);//画出计时器
}