Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android在视图类中关闭_Java_Android_View_Countdown_Ondraw - Fatal编程技术网

Java Android在视图类中关闭

Java Android在视图类中关闭,java,android,view,countdown,ondraw,Java,Android,View,Countdown,Ondraw,我试图使一个圆圈在3秒钟后出现,然后在3秒钟后消失 public class TestView extends View{ public TestView(Context context) { super(context); // TODO Auto-generated constructor stub } @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method st

我试图使一个圆圈在3秒钟后出现,然后在3秒钟后消失

public class TestView extends View{

public TestView(Context context) {
    super(context);
    // TODO Auto-generated constructor stub
}

@Override
protected void onDraw(Canvas canvas) {
    // TODO Auto-generated method stub
    super.onDraw(canvas);
    canvas.drawColor(Color.RED);

    Paint circle = new Paint();
    circle.setColor(Color.BLUE);


    CountDownTimer count = new CountDownTimer(3000, 1000) {

        public void onTick(long millisUntilFinished) {

        }

        public void onFinish() {

            CountDownTimer count = new CountDownTimer(3000, 1000) {

                public void onTick(long millisUntilFinished) {
                    canvas.drawCircle(100, 100, 40, circle);

                }

                public void onFinish() {

                }

             }.start();

        }

     }.start();



}
这是完成这项任务的好方法吗?
但他让我做画布和油画作为最后的作品。如何删除圆?

添加一个布尔变量=shouldDrawCircle=true,使用true初始化它,当您绘制圆时,将其设为false,然后在绘制移除之前,测试该变量以了解是否应该绘制或移除圆,如果shouldDrawCircle==true//绘制圆,否则,将其移除