title: Background just comes up black when using Canvas
body: <p>I'm trying to learn how to use canvas to create simple graphics, but right now it is refusing to draw anything and instead only creates a black background.</p>
  
  <p>Here's the MainActivity:</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      if (id == R.id.action_settings) {
          return true;
      }
      return super.onOptionsItemSelected(item);
  }
  }
  </code></pre>
  
  <p>xml file:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context="com.example.canvastesting.MainActivity" &gt;
  
  &lt;com.example.canvastesting.DrawingPanel android:id="@+id/DrawingPanel01" android:layout_width="wrap_content"
  android:layout_height="wrap_content" android:maxHeight="40dip"&gt;
  &lt;/com.example.canvastesting.DrawingPanel&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>DrawingPanel class:</p>
  
  <pre><code>public class DrawingPanel extends SurfaceView implements SurfaceHolder.Callback {
  PanelThread canvasthread;
  
  public DrawingPanel(Context context, AttributeSet attrs) {
      super(context, attrs);
      getHolder().addCallback(this);
      canvasthread = new PanelThread(getHolder(), this);
      setFocusable(true);
      // TODO Auto-generated constructor stub
  }
  
  @Override
  public void onDraw(Canvas canvas){
      //Draw stuff here
      canvas.drawColor(Color.TRANSPARENT);
  }
  
  @Override
  public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
      // TODO Auto-generated method stub
  
  }
  
  @Override
  public void surfaceCreated(SurfaceHolder arg0) {
      canvasthread.setRunning(true);
      canvasthread.start();       
  }
  
  @Override
  public void surfaceDestroyed(SurfaceHolder arg0) {
      boolean retry = true;
      canvasthread.setRunning(false);
      while(retry){
          try{
              canvasthread.join();
              retry = false;
          }
          catch(InterruptedException e){
  
          }
      }
  }
  }
  </code></pre>
  
  <p>And my PanelThread class:
      public class PanelThread extends Thread{
      private SurfaceHolder _surfaceHolder;
      private DrawingPanel _panel;
      private boolean _run = false;</p>
  
  <pre><code>public PanelThread(SurfaceHolder surfaceHolder, DrawingPanel panel){
      _surfaceHolder = surfaceHolder;
      _panel = panel;
  }
  
  public void setRunning(boolean run){
      _run = run;
  }
  
  @Override
  public void run(){
      Canvas c;
      while(_run){
          c = null;
          try{
              c = _surfaceHolder.lockCanvas(null);
              synchronized(_surfaceHolder){
                  _panel.onDraw(c);
              }
          }
          finally{
              if(c!=null){
                  _surfaceHolder.unlockCanvasAndPost(c);
              }
          }
      }
  }
  
  }
  </code></pre>
  
  <p>Any help would be much appreciated! I'm completely stumped on this problem.</p>