ImageView#getId() gets the id of the ImageView, not the image displayed in the view. So img.getId() should return R.id.imageView1 not R.drawable.picture_1. So what problem are you actually trying to solve? Because comparing the id of the Drawable and the id of the ImageView is not a useful exercise.