title: Drawing on Button Click
body: <p>I want to draw a rectangle on a button click. All the research I've done says to me that this should work, but it doesn't. I simply can't understand why.</p>
  
  <p>In my MainActivity class I have:</p>
  
  <pre><code>Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  public Canvas canvas = new Canvas(b);
  </code></pre>
  
  <p>In my constructor I have:</p>
  
  <pre><code> button.setOnClickListener(new View.OnClickListener()
      {
          public void onClick(View v)
          {
              Paint paint = new Paint();
              paint.setColor(Color.GREEN);
              //paint.setStrokeWidth(5);
              canvas.drawRect(0, 0, 50, 50, paint);
              Log.e("Blah Blah Blah", "Blah Blah, Blah");
          }
      });
  </code></pre>
  
  <p>It does go into the function, which I see because when I click it the "Blah Blah Blah" is logged, but it doesn't draw the rectangle. </p>
  
  <p>Any ideas?</p>