Eddev
Eddev

Reputation: 900

android - Sleep() and then draw

I want to sleep and then draw in onDraw:

protected void onDraw(Canvas canvas) {
    if (_rectPath) {
        canvas.drawPath(mRectPath, mFillPaint);
        // SLEEP HERE for 5 seconds
        canvas.drawPath(mRectPath, mNPaint);
    }
    canvas.drawPath(mPath, mPaint);
}

How would I implement sleeping for 5 sec? Basically I want it to wait 5 sec and then draw the next path, mNPaint.

Thanks!

Upvotes: 0

Views: 943

Answers (1)

Krish
Krish

Reputation: 3885

You could use this method. Initialize Handler out side the ondraw method

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);

Upvotes: 3

Related Questions