Vishwas Shukla
Vishwas Shukla

Reputation: 29

How to set onTouchListener on BitMap

How do I set an onTouchListener for a Bitmap. e.g

   pongball = BitmapFactory.decodeResource(getResources(), R.drawable.pongball);

Upvotes: 0

Views: 1447

Answers (1)

Andy Res
Andy Res

Reputation: 16043

Wrap the bitmap object into a View, for example into an ImageView:

imageView.setImageBitmap(pongball);

then set the touch listener to the ImageView:

imageView.setOnTouchListener(new OnTouchListener() {
    @Override
    public boolean onTouch(View arg0, MotionEvent arg1) {
        return false;
    }
});

Upvotes: 3

Related Questions