title: Android gridview OnItemClickListener
body: <p>I successfully created a custom gridview(with images and texts). Now I want to write an OnItemClickListener method.I can get the position on OnItemClickListener method, but I want to be able to click "Friend" and see "Item clicked : Friend"</p>
  
  <p>How can I get the select string instead of the position?
  Here is my source code</p>
  
  <pre><code>public class Item {
  Bitmap image;
  String title;
  
  public Item(Bitmap image, String title) {
      super();
      this.image = image;
      this.title = title;
  }
  public Bitmap getImage() {
      return image;
  }
  public void setImage(Bitmap image) {
      this.image = image;
  }
  public String getTitle() {
      return title;
  }
  public void setTitle(String title) {
      this.title = title;
  }
  
  
  
  public class CustomGridViewAdapter extends ArrayAdapter&lt;Item&gt; {
  Context context;
  int layoutResourceId;
  ArrayList&lt;Item&gt; data = new ArrayList&lt;Item&gt;();
  public static Item item ;
  
  public CustomGridViewAdapter(Context context, int layoutResourceId,
          ArrayList&lt;Item&gt; data) {
      super(context, layoutResourceId, data);
      this.layoutResourceId = layoutResourceId;
      this.context = context;
      this.data = data;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      View row = convertView;
      RecordHolder holder = null;
  
      if (row == null) {
          LayoutInflater inflater = ((Activity) context).getLayoutInflater();
          row = inflater.inflate(layoutResourceId, parent, false);
  
          holder = new RecordHolder();
          holder.txtTitle = (TextView) row.findViewById(R.id.item_text);
          holder.imageItem = (ImageView) row.findViewById(R.id.item_image);
          row.setTag(holder);
      } else {
          holder = (RecordHolder) row.getTag();
      }
  
      item= data.get(position);
      holder.txtTitle.setText(item.getTitle());
      holder.imageItem.setImageBitmap(item.getImage());
      return row;
  
  }
  
  public static class RecordHolder {
      public static TextView txtTitle;
      ImageView imageItem;
  
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public class MainActivity extends Activity {
  GridView gridView;
  ArrayList&lt;Item&gt; gridArray = new ArrayList&lt;Item&gt;();
  CustomGridViewAdapter customGridAdapter;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      // set grid view item
      Bitmap homeIcon = BitmapFactory.decodeResource(this.getResources(),
              R.drawable.home);
      Bitmap userIcon = BitmapFactory.decodeResource(this.getResources(),
              R.drawable.personal);
  
      gridArray.add(new Item(homeIcon, "Home"));
      gridArray.add(new Item(userIcon, "User"));
      gridArray.add(new Item(homeIcon, "House"));
      gridArray.add(new Item(userIcon, "Friend"));
      gridArray.add(new Item(homeIcon, "Home"));
      gridArray.add(new Item(userIcon, "Personal"));
      gridArray.add(new Item(homeIcon, "Home"));
      gridArray.add(new Item(userIcon, "User"));
      gridArray.add(new Item(homeIcon, "Building"));
      gridArray.add(new Item(userIcon, "User"));
      gridArray.add(new Item(homeIcon, "Home"));
      gridArray.add(new Item(userIcon, "xyz"));
  
      gridView = (GridView) findViewById(R.id.gridView1);
      customGridAdapter = new CustomGridViewAdapter(this, R.layout.row_grid,
              gridArray);
      gridView.setAdapter(customGridAdapter);
      gridView.setOnItemClickListener(new OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                  int position, long id) {
              Toast.makeText(getApplicationContext(),
                      "Item Clicked: " + position, Toast.LENGTH_SHORT).show();
  
          }
      });
  }
  </code></pre>
  
  <p>}</p>