Skip to main content

Posts

Showing posts with the label imageview

Android ImageView onClickListener won"t work

I am using a View Object named CameraView that implements View and uses a Hud-Object to create the HUD for a game. In this Hud-Class i use a LinearLayout to place ImageViews. I want these ImageViews to be clickable and to be able to fire some Code on Click. Thats why I use the onClickListener for each of the ImageViews. But it won't work at all. Here is the specific Code of both classes: CameraView protected void onDraw(Canvas canvas) { //GameTimer hud.draw(canvas); // and make sure to redraw asap invalidate(); } HUD public class Hud{ public TextElement gameTimer; CameraView mCameraView; private HashMap<Integer, Item> mItems = new HashMap<Integer, Item>(); private Integer mScreenWidth; private Integer mScreenHeight; //private ImageView imgView; private HashMap<Integer, ImageView> imgViews = new HashMap<Integer, ImageView>(); private LinearLayout ll; public Hud(CameraView cameraView){ mCameraView = cameraView; mScreenWidth