title: Create a clickable image in a GridView in Android
body: <p>I have images displayed in a GridView as in <a href="http://developer.android.com/guide/tutorials/views/hello-gridview.html" rel="nofollow noreferrer">this tutorial</a>.  I want to be able to click on a single image and do other events and I need to know what image was clicked.</p>
  
  <p>Do I have to add imageView.onKeyDown(keyCode, event) in the ImageAdapter class?  Here is the code as it currently exists:</p>
  
  <pre><code>@Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView;
    if (convertView == null) {  
      // if it's not recycled, initialize some attributes
      imageView = new ImageView(mContext);
      imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
      imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
      imageView.setPadding(8, 8, 8, 8);
      //does this need imageView.onKeyDown(keyCode, event)?
    } 
    else {
      imageView = (ImageView) convertView;
    }
  
    imageView.setImageResource(mThumbIds[position]);
    return imageView;
  }
  </code></pre>
  
  <p>How will it indicate what image was clicked? How do I create the proper handler?</p>