カウントダウンタイマーを作成してキャンバスに表示しようとしています。これが私がそれを表示する方法です。
public class DrawView extends SurfaceView {
private Paint textPaint = new Paint();
Bitmap GameBg;
DisplayMetrics metrics;
int screenWidth = 0;
int screenHeight = 0;
Rect dest;
Paint paint;
String timer;
public DrawView(Context context) {
super(context);
// Create out paint to use for drawing
textPaint.setARGB(255, 200, 0, 0);
textPaint.setTextSize(60);
// This call is necessary, or else the
// draw method will not be called.
setWillNotDraw(false);
GameBg = BitmapFactory.decodeResource(getResources(),R.drawable.gembackground);
metrics = context.getResources().getDisplayMetrics();
screenWidth = metrics.widthPixels;
screenHeight = metrics.heightPixels;
dest = new Rect(0, 0, screenWidth, screenHeight);
paint = new Paint();
paint.setFilterBitmap(true);
new CountDownTimer(60000, 1000) {
public void onTick(long millisUntilFinished) {
timer = String.valueOf(millisUntilFinished / 1000);
}
public void onFinish() {
}
}.start();
}
@Override
protected void onDraw(Canvas canvas){
// A Simple Text Render to test the display
canvas.drawBitmap(GameBg, null, dest, paint);
canvas.drawText(timer, screenWidth - 50, screenHeight - 50, paint);
}
}
タイマーは表示できますが、カウントダウンしません。何か案は?