title: Custom ImageView invalidate not working
body: <p>i created my own ImageView which draws shapes..
  i also have 4 radio buttons for each shape.
  on the ondraw the method checks which radio is checked and draws the shape based on this.
  i wanted the ImageView to display a different shape every time i check a radio button- so i invalidated it on an OnCheckedChangeListener but its not redrawing, just staying the same.</p>
  
  <pre><code>    package com.example.androidshapes;
  
  import android.app.Activity;
  import android.graphics.Bitmap;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.graphics.ColorFilter;
  import android.graphics.drawable.Drawable;
  import android.graphics.drawable.ShapeDrawable;
  import android.graphics.drawable.shapes.*;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.ImageView;
  import android.widget.RadioGroup;
  import android.widget.RadioGroup.OnCheckedChangeListener;
  
  
  public class MainActivity extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      final RadioGroup radio=(RadioGroup) findViewById(R.id.radioGroup);
      final CustomImageView v= (CustomImageView) findViewById(R.id.c1);
      OnCheckedChangeListener on= new OnCheckedChangeListener() 
      {
          public void onCheckedChanged(RadioGroup group, int checkedId) {
  
  
              runOnUiThread(new Runnable() {
                  public void run() {
                   v.invalidate();
                  }
              });
  
          }
      };
      radio.setOnCheckedChangeListener(on);
  
  
  
  
  }
  
  
  @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>}</p>
  
  <p>this is my main activity</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.androidshapes.MainActivity" &gt;
  
  &lt;com.example.androidshapes.CustomImageView
      android:id="@+id/c1"
      android:layout_width="200dp"
      android:layout_height="200dp"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true" /&gt;
  
  &lt;RadioGroup
      android:id="@+id/radioGroup"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true" &gt;
  
      &lt;RadioButton
          android:id="@+id/radioCircle"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:checked="true"
          android:text="Circle" /&gt;
  
      &lt;RadioButton
          android:id="@+id/radioRectangle"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:checked="true"
          android:text="Rectangle" /&gt;
  
      &lt;RadioButton
          android:id="@+id/radioLine"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Line" /&gt;
  
      &lt;RadioButton
          android:id="@+id/radioTriangle"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Triangle" /&gt;
  
  &lt;/RadioGroup&gt;
  </code></pre>
  
  <p></p>
  
  <p>and this is the xml</p>
  
  <pre><code>public class CustomImageView extends ImageView
  </code></pre>
  
  <p>{</p>
  
  <pre><code>public CustomImageView(Context context, AttributeSet attrs)
  {
      super(context, attrs);
  
  
      // TODO Auto-generated constructor stub
  }
  @Override
  protected void onDraw(Canvas canvas)
  {
      Paint paint  = new Paint(Paint.LINEAR_TEXT_FLAG);
      paint.setColor(Color.BLACK);
      paint.setTextSize(50.0F);
      View view = View.inflate(this.getContext(), R.layout.activity_main, null);
      RadioGroup radio=(RadioGroup) view.findViewById(R.id.radioGroup);
      int id=radio.getCheckedRadioButtonId();
  
      if(id==R.id.radioCircle)
      {
          Circle c=new Circle(new Point(this.getHeight()/2,this.getWidth()/2), 100,"BLACK", 5, "BLACK");
          canvas.drawCircle((float) c.getCenter().getX(), (float) c.getCenter().getY(), (float) c.getRadius(), paint);
      }
      else
      {
          if(id==R.id.radioRectangle)
          {
              Rectangle r=new Rectangle(new Point(this.getHeight()/2,this.getWidth()/2), 200, 100, "Black", 5, "Black");
              canvas.drawRect((float)r.topLeft().getX(), (float)r.topLeft().getY(), (float)r.bottomRight().getX(), (float)r.bottomRight().getY(), paint);
          }
          else
          {
              if(id==R.id.radioLine)
              {
                  Line l=new Line(new Point(0,0), new Point(100,100),5, "Black");
                  canvas.drawLine((float)l.getP1().getX(), (float)l.getP1().getY(), (float)l.getP2().getX(), (float)l.getP2().getY(), paint);
              }
          }
  
      }
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>i dont see why its not refreshing. please help me</p>