I want draw bmp file on my own soft-keyboard. Soft keyboard working 
successully.

My Draw class:

public class Keyboard_Draw extends SurfaceView implements
        SurfaceHolder.Callback {
public Keyboard_Thread mKeyb_Thread;private SurfaceHolder mHolder;private 
static final String TAG = "Sample::Keyboard_Draw";
public Keyboard_Draw(Context context) {
    super(context);
    Log.i(TAG, "Initialize class");
    try {
        mHolder = getHolder();
        mHolder.addCallback(this);
        mKeyb_Thread = new Keyboard_Thread(getContext(), mHolder);

    } catch (Exception e) {
        Log.e(TAG, "Failed to initialize " + e);
    }}

Keyboard_Thread - it's thread for drawing:

public class Keyboard_Thread extends Thread {...

public Keyboard_Thread(Context context, SurfaceHolder surfaceHolder) {...public 
void draw() {
        try {
            Paint shadow = new Paint();
            shadow.setColor(0xBBFF0000);
            Bitmap bmp;
            bmp = bitmap;
            canvas = surfaceHolder.lockCanvas();
            synchronized (surfaceHolder) {
            if (canvas != null) {
                Log.i(TAG, "drawing on Keyboard");
                canvas.drawBitmap(bmp,left,top, shadow);
                }
            }
            if (canvas != null) {
                surfaceHolder.unlockCanvasAndPost(canvas);
            }
            bmp.recycle();
        } catch (Exception e) {
            Log.e(TAG, "Failed to draw. Exception thrown: "
                    + e);
        }
    }

When i debugging, canvas already=null. What's wrong?

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

Reply via email to