title: Android: Touch event for select item on a canvas
body: <p>I have many circles drawn on the Canvas and want to know which of them is touched.
  One solution is to create a bitmap as the size of the screen and draw a copy of the circles that are on the screen only with a different color so that when the call getPixel () the bitmap poosso recognize which circle is clicked. My problem is that I do not know how to draw a circle on a bitmap ... that is, how to draw the bitmap as a drawing normally on Canvas. </p>
  
  <pre><code>Paint paint;
  Bitmap screen;
  
  int w,h;
  int px=-1,py=-1; //coordinate 
  
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
      //registriamo le dimensioni della view
      w=MeasureSpec.getSize(widthMeasureSpec);
      h=MeasureSpec.getSize(heightMeasureSpec);
      setMeasuredDimension(w,h);
  }
  
  public CustomView(Context context, AttributeSet attrs) {
      super(context, attrs);
  
      Bitmap.Config conf = Bitmap.Config.ARGB_8888;  //Each pixel is stored on 4 bytes
      screen=Bitmap.createBitmap(w,h, conf);
  
      paint=new Paint(); // pennello
      paint.setColor(Color.RED);   
      paint.setAntiAlias(true);   
  }
  
  @Override
  protected void onDraw(Canvas canvas) {
      // TODO Auto-generated method stub
      super.onDraw(canvas);
      if(px==-1&amp;&amp;py==-1){ // se non abbiamo ancora settato le coordinate, posizioniamo la bmp al centro
          px=w/2-bw/2; //metà della larghezza view, meno metà della figura
          py=h/2-bh/2; //metà dell'altezza view, meno metà della figura
      }
  
      canvas.drawCircle(px, py, 70, paint);       
  }
  
  public void updatePosition(int x, int y) {      
  
      invalidate();
  }
  }
  </code></pre>