title: Clearing canvas with Canvas.drawColor()
body: <p>i'm attempting to change the background image of a custom View with some success.  the image will change but the problem is that i still see traces of the old image.  when i attempt to clear the canvas before drawing the new image, it doesn't appear to work.  i create a bitmap to store the image.  when changing the image, i call Canvas.drawColor() before drawing the new image but the old image persists. i've tried drawColor(0), drawColor(Color.BLACK), c.drawColor(0, PorterDuff.Mode.CLEAR), and none of the above works.  as such, i had to post this for review from more experienced minds than mine.</p>
  
  <p>the actual code is as follows:</p>
  
  <pre><code>private int bgnd;
  private boolean switching;
  
  public void setBgnd(int incoming){
      switching = true;
      switch (incoming){
  
      case R.drawable.image1:
          bgnd = incoming;
          this.invalidate();
          break;
  
      case R.drawable.image2:
          bgnd = incoming;
          this.invalidate();
          break;
  
      }
  }
  
  
  
  protected void onDraw(Canvas c){
      if(switching == true){
          Bitmap b = BitmapFactory.decodeResource(getResources(), bgnd);
          c.drawColor(0, PorterDuff.Mode.CLEAR);
          c.drawBitmap(b, 0, 0, null);
          switching = false;
  
      }else{
          Bitmap b = BitmapFactory.decodeResource(getResources(), bgnd);
          c.drawBitmap(b, 0, 0, null);
      }
  }
  </code></pre>