android - Sleep()然后绘制

时间:2016-04-15 18:36:37

标签: java android sleep thread-sleep

我想睡觉,然后画上onDraw:

--hostname=quickstart.cloudera    Required: pseudo-distributed configuration assumes this hostname
--privileged=true                 Required: for HBase, MySQL-backed Hive metastore, Hue, Oozie, Sentry, and Cloudera Manager, and possibly others
-t                                Required: once services are started, a Bash shell takes over and will die without this
-i                                Required: if you want to use the terminal, either immediately or attach later
-p 8888                           Recommended: maps the Hue port in the guest to another port on the host
-p [PORT]                         Optional: map any other ports (e.g. 7180 for Cloudera Manager, 80 for a guided tutorial)
-d                                Optional: runs the container in the background

我如何实现睡眠5秒? 基本上我希望它等待5秒然后绘制下一条路径mNPaint。

谢谢!

1 个答案:

答案 0 :(得分:2)

您可以使用此方法。将Onler方法初始化为ondraw方法

Handler handler = new Handler();
And inside onDraw method


    handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    //Draw the previous paths.
                    // Adjust the paths here and draw it
                    invalidate();
                }
            }, 5 * 1000);