SurfaceView null canvas problems when using PopupWindow
<p>So as the title suggests I'm having some trouble getting this to work. The idea is to create a new surface within the popup window for me to draw to. Here is the code I'm using which is largely borrowed from examples.</p>

<pre><code>public class inventoryWindow extends Activity {

PopupWindow popUp;
Resources mRes;
MyDraw mydraw;

protected inventoryWindow(Resources res) {
    Context context = Panel.mcontext;
    mRes = res;
    popUp = new PopupWindow(context);
    mydraw = new MyDraw(context);

    popUp.setContentView(mydraw);
}

public void show(View target) {
    popUp.showAtLocation(target, Gravity.BOTTOM, 10, 10);
    popUp.update(50, 50, 600, 300);
}

public void hide() {
    popUp.dismiss();
}

class MyDraw extends SurfaceView implements Callback {

    private MyThread myThread;
    private Bitmap bmp;

    public MyDraw(Context context) {
        super(context);
        getHolder().addCallback(this);
        myThread = new MyThread(this);
        bmp = BitmapFactory.decodeResource(mRes, R.drawable.icon);
    }

    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
        // TODO
    }

    @Override 
    public void surfaceCreated(SurfaceHolder holder) {
        if(!myThread.isAlive()) {
            myThread = new MyThread(this);
            myThread.setFlag(true);
            myThread.start();
        }
    }

    public void surfaceDestroyed(SurfaceHolder holder) {
        // TODO
    }

    protected void doDraw(Canvas canvas) {
        canvas.drawColor(Color.BLACK);
        canvas.drawBitmap(bmp, 0, 0, null);

    }
}

// THREAD
class MyThread extends Thread {
    private SurfaceHolder mHolder;
    private MyDraw mDraw;
    boolean mRun = false;

    public MyThread(MyDraw draw) {
        mDraw = draw;
        mHolder = mDraw.getHolder();

    }

    public void setFlag(boolean run) {
        mRun = run;
    }

    @Override
    public void run() {
        Canvas canvas = null;
        while (mRun) {
            try {
                canvas = mHolder.lockCanvas();  
            } finally {
                if (canvas != null) {
                    mDraw.doDraw(canvas);
                    mHolder.unlockCanvasAndPost(canvas);
                }
            }
        }
    }
}
}
</code></pre>

<p>I'm using the following code to call with.</p>

<pre><code>inventoryWindow inventory = new inventoryWindow(mPanel.getResources());

inventory.show(mPanel);
</code></pre>

<p>My problem seems to be that the canvas is always null so the final block of the thread never gets called. I've been scratching my head over this for a while because im using almost identical code to this elsewhere in my game. To clarify I'm adding the popup view containing the surfaceView on top of the surfaceView 'mPanel'. i see the outline of the popup window but the centre is totally transparent. thanks.</p>
