说我要画一条线,然后等五秒钟,然后再画一条线。我有这样的方法:
public void onDraw(Canvas canvas) {
int w = canvas.getWidth();
int h = canvas.getHeight();
canvas.drawLine(w/2, 0, w/2, h-1, paint);
// PAUSE FIVE SECONDS
canvas.drawLine(0, h/2, w-1, h/2, paint);
}
如何暂停?
最佳答案
你可以像这样使用 CountDownTimer :
public void onDraw(Canvas canvas) {
int w = canvas.getWidth();
int h = canvas.getHeight();
canvas.drawLine(w/2, 0, w/2, h-1, paint);
// PAUSE FIVE SECONDS
new CountDownTimer(5000,1000){
@Override
public void onTick(long miliseconds){}
@Override
public void onFinish(){
//after 5 seconds draw the second line
canvas.drawLine(0, h/2, w-1, h/2, paint);
}
}.start();
}
问候,
关于android - 如何在 Android 上绘制下一个东西之前暂停 5 秒?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6665967/