title: Android: Clickable piechart
body: <p>I need a piechart for my App to display some data in different sections.
  the piechart is ready and it also works fine but i need a clickable event when touched on a particular section in pie chart .Please let me know the code
  Thanks in advance. 
  this is my android code</p>
  
  <pre><code>  public class PieActivity extends Activity 
  {
  /** Called when the activity is first created. */
  float values[]={300,700,100,500};
  
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      LinearLayout linear=(LinearLayout) findViewById(R.id.linear);
      values=calculateData(values);
      linear.addView(new MyGraphview(this,values));
  
  }
  private float[] calculateData(float[] data)
  {
      // TODO Auto-generated method stub
      float total=0;
      for(int i=0;i&lt;data.length;i++)
      {
          total+=data[i];
      }
      for(int i=0;i&lt;data.length;i++)
      {
      data[i]=360*(data[i]/total);            
      }
      return data;
  
  }
  public class MyGraphview extends View
  {
      private Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG);
      private float[] value_degree;
      private int[] COLORS={Color.BLUE,Color.GREEN,Color.GRAY,Color.CYAN,Color.RED};
      RectF rectf = new RectF (10, 10, 200, 200);
      int temp=0;
      public MyGraphview(Context context, float[] values) {
  
          super(context);
          value_degree=new float[values.length];
       //   System.out.println("values"+value_degree);
          for(int i=0;i&lt;values.length;i++)
          {
              value_degree[i]=values[i];
              System.out.println("degree"+value_degree[i]);
          }
      }
      @Override
      protected void onDraw(Canvas canvas) {
          // TODO Auto-generated method stub
          super.onDraw(canvas);
  
          for (int i = 0; i &lt; value_degree.length; i++) {//values2.length; i++) {
              if (i == 0) {
                  paint.setColor(COLORS[i]);
                  canvas.drawArc(rectf, 0, value_degree[i], true, paint);
              } 
              else
              {
                      temp += (int) value_degree[i - 1];
                      paint.setColor(COLORS[i]);
                      canvas.drawArc(rectf, temp, value_degree[i], true, paint);
              }
          }
      }
  
  }
  }
  </code></pre>