title: How to detect single tap on canvas drawings or bitmaps using onTouchListener?
body: <p>The objective of this game is similar to that of a bubble popping game. Each time a bubble is touched, an interaction/event happens. </p>
  
  <p>So far this is what i have. It's kinda messy since i am new at this, but my professor told me to use onTouch(view v, motionevent event) and in that method, i will use something like event.getSource(); for me to be able to create an interaction with methods serving the purpose of a touchable drawing/bitmap image.</p>
  
  <p>Any advice or help would be great! Many thanks.</p>
  
  <pre><code>public class MainActivity extends Activity implements OnTouchListener {
  
  OurView v;
  Bitmap icon1, icon2, icon3;
  float x,y;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      v = new OurView(this);
      v.setOnTouchListener(this);
      icon1 = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
      icon2 = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
      icon3 = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
      x = y = 0;
      setContentView(v);
  }
  
  @Override
  protected void onPause() {
      super.onPause();
      v.pause();
  }
  
  @Override
  protected void onResume() {
      super.onResume();
      v.resume();
  }
  
  
  public class OurView extends SurfaceView implements Runnable {
  
      Thread t = null;
      SurfaceHolder holder;
      boolean isItOK = false;
  
      public OurView(Context context) {
          super(context);
          holder = getHolder();
      }
  
      @Override
      public void run() {
          while (isItOK == true){
              if (!holder.getSurface().isValid()){
                  continue;
              }
              Canvas c = holder.lockCanvas();
              c.drawARGB(255, 100, 120, 10);
              c.drawBitmap(icon1, x=50, y=100, null);
              c.drawBitmap(icon2, x=180, y=100, null);
              c.drawBitmap(icon3, x=310, y=100, null);
              holder.unlockCanvasAndPost(c);
          }
      }
  
      public void pause() {
          isItOK = false;
          while(true){
              try{
                  t.join();
              }catch (InterruptedException e){    
                  e.printStackTrace();
                  }
              break;
              }
          t = null;
      }
  
      public void resume(){
          isItOK = true;
          t = new Thread(this);
          t.start();
      }
  }
  
  
  @Override
  public boolean onTouch(View v, MotionEvent me) {
  
      try {
          Thread.sleep(50);
      } catch (InterruptedException e) {
          e.printStackTrace();
      }
  
      me.getSource();
  
  
      switch(me.getAction()){
      case MotionEvent.ACTION_DOWN:
          x = me.getX();
          y = me.getY();
          break;
      case MotionEvent.ACTION_UP:
          break;
      case MotionEvent.ACTION_MOVE:
  
          break;
      }
      return true;
  }
  </code></pre>
  
  <p>}</p>