how to make bitamap image invisible on button click
<p>I am developing hunting game for that I have bitmap images(parts of deer like head,stomach,legs) of deer. When I click on particular image say suppose on head it should be removed. I am using canvas and surface view for moving the gun how can make invisible the image when I click on that. I have used the following code but I am unable to get .</p>

<pre><code>public boolean onTouchEvent(MotionEvent event)
{
int action = event.getAction();

int x = event.getX()  // or getRawX();

int y = event.getY();


switch(action){

case MotionEvent.ACTION_DOWN:

    if (x &gt;= xOfYourBitmap &amp;&amp; x &lt; (xOfYourBitmap + yourBitmap.getWidth())
            &amp;&amp; y &gt;= yOfYourBitmap &amp;&amp; y &lt; (yOfYourBitmap + yourBitmap.getHeight())) {

        //tada, if this is true, you've started your click inside your bitmap
    }
    break;
}
</code></pre>

<p><em><strong></em>**<em>*</em>**<em>*</em>**</strong><em>my code starts here</em><strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>***</strong></p>

<pre><code>public class Gun extends Activity implements  OnClickListener,OnTouchListener
{   
   Surfacevv srfv;

  float x,y,sX,sY,dX,dY,aniX,aniY,scaledX,scaledY,fX,fY;

  Bitmap img,img1,img2,img3,img4,img5,img6,img0;

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

        srfv=new Surfacevv(this);

        setContentView(srfv);

        srfv.setOnTouchListener(this);

        x=0;

        y=0;

 //** images are gun ,second screen is background image and u1,u3,u4,u5 are parts of deer**

     img=BitmapFactory.decodeResource(getResources(), R.drawable.gun);
    // 
         img0=BitmapFactory.decodeResource(getResources(), R.drawable.secondscreen);

        img1=BitmapFactory.decodeResource(getResources(), R.drawable.u1);

        img2=BitmapFactory.decodeResource(getResources(), R.drawable.u3);

    img3=BitmapFactory.decodeResource(getResources(), R.drawable.u4);

    img4=BitmapFactory.decodeResource(getResources(), R.drawable.u5);

    img5=BitmapFactory.decodeResource(getResources(), R.drawable.u6);

    img6=BitmapFactory.decodeResource(getResources(), R.drawable.u7);

}

        protected void onPause() {

        super.onPause();

        srfv.pause();
    }

    protected void onResume() {

        super.onResume();

        srfv.resume();

    }
public boolean onTouch(View v, MotionEvent event) 
{ 
    x=event.getX();

    y=event.getY();

    switch(event.getAction())
{
    case MotionEvent.ACTION_DOWN:

        if (x &gt;= 47 &amp;&amp; x &lt; (47 +img1.getWidth())

            &amp;&amp; y &gt;= 50 &amp;&amp; y &lt; (50 + img1.getHeight()))
        sX = event.getX();

        sY = event.getY();

        break;
    case MotionEvent.ACTION_MOVE:

        fX = event.getX();

        fY = event.getY();

        dX = fX-sX;

        dY = fY-sY;

        break;
    }

    return true;
}
public class Surfacevv extends SurfaceView implements Runnable{

    SurfaceHolder sholder;

    Thread thread;

    boolean isRunning=false;

    public Surfacevv(Context context) {

        super(context);

        sholder=getHolder();

    }
        public void pause(){

            isRunning = false;

            while(true){

                try {
                    thread.join();

                } catch (InterruptedException e) {

                    e.printStackTrace();
                }
                break;
            }
            thread = null;
        }
        public void resume(){
            isRunning = true;
            thread = new Thread(this);
            thread.start();
        }
    public void run() {
        // TODO Auto-generated method stub
        while(isRunning){
            if(!sholder.getSurface().isValid())
                continue;

            Canvas canvas = sholder.lockCanvas();

// Here I am setting different parts of the deer according to x and y pixels  

            canvas.drawBitmap(img0, 0,0, null);
            canvas.drawBitmap(img1, 50, 50, null);
            canvas.drawBitmap(img2, 47, 50, null);
            canvas.drawBitmap(img3, 100, 140, null);
            canvas.drawBitmap(img4, 130, 140, null);
            canvas.drawBitmap(img5, 120, 138, null);
            canvas.drawBitmap(img6, 90,135,null);
            //canvas.(02, 02, 150);

            if (x != 0 &amp;&amp; y != 0){
                canvas.drawBitmap(img, x-(img.getWidth()/2), y-(img.getHeight()/2), null);
            }

            if (fX != 0 &amp;&amp; fY != 0){
                canvas.drawBitmap(img, fX-(img.getWidth()/2)-aniX,  fY-(img.getHeight()/2)-aniY, null);

            }
            //aniX = aniX + scaledX;
            //aniY = aniY + scaledY;


            sholder.unlockCanvasAndPost(canvas);
        }
    }
    }
public void onClick(View v) {

     if(v.getId()==R.drawable.u1)
        {
          img1.setVisibility(4);
        }else if(v.getId()==R.drawable.u3)
        {
            img2.setVisibility(4);
                     //setVisible(false);
        }else if(v.getId()==R.drawable.u4)
        {
            img3.setVisibility(4);
                    //setVisible(false);
        }else if(v.getId()==R.drawable.u5)
        {
            //setVisible(false);
            img4.setVisibility(4);
        }else if(v.getId()==R.drawable.u6)
        {
            img5.setVisibility(4);
        }else if(v.getId()==R.drawable.u7)
        {
            img6.setVisibility(4);
        }
}
</code></pre>
