The calendar app has a costom view,  here is another code snippet
@Override
    protected void onDraw(Canvas canvas) {
        if (mRedrawRequired) {
            // if canvas is null, we get the canvas prepared for drawing,
and
            // the background bitmap is needed because we do not need the
draw
            // the view every time(such as the parent calls scrollTo()
method,
            // etc.), only draw it when needed. when onDraw method is called
            // again, by default if has nothing done, the view will be
cleared.
            // Here we keep the background bitmap saved, we just show the
bitmap
            // instead of draw the canvas.
            if (null == mCanvas) {
                Log.i(TAG, "prepareCanvas.");
                prepareCanvas(mVisibleWidth, mVisibleHeight);
            }
            // else means we can not just show the background bitmap, which
is
            // not enough, we should clear the bitmap and redraw it.
            // This statement clear will clear the canvas
            mCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
            drawContent();
            mRedrawRequired = false;
        }
        if (null != *mContentBitmap*) {
            canvas.drawBitmap(mContentBitmap, mBitmapRect, mBitmapRect,
mPaint);
        }
    }

take attention the mContentBitmap here, this is the cache of the canvas, if
it is unnessarry to redraw your whole view, just call canvas.drawBitmap()
method

-- 
Regards

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to