title: Custom adapter: get item number of clicked item in inflated listview
body: <p>I have a custom baseadapter which does some lazy loading of some images, and then inflating the layout so I end up with a listview where I have both image and text in one row.</p>
  
  <p>When the user presses one item of the listview, say for example item 0 (top item), I want to show a dialog box with some specific content. This content depends on the item number - so the content shown for item 0 is not the same as for item 1, and so on.</p>
  
  <p>Here is the <code>getView</code> method of the custom adapter:</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent)
  {
      View vi=convertView;        
      if(convertView==null)
      {
          vi = inflater.inflate(R.layout.facebook_item, null);                        
          vi.setClickable(true);
          vi.setOnClickListener(new OnClickListener()
          {
              @Override
              public void onClick(View v)
              {                   
                  String s = "test";
                  Toast.makeText(myContext, s, Toast.LENGTH_SHORT).show();
              }
          });
      }        
  
      TextView text=(TextView)vi.findViewById(R.id.text);
      ImageView image=(ImageView)vi.findViewById(R.id.image);
      text.setText(msg[position]);
      text.getLineCount();
      imageLoader.DisplayImage(data[position], image);
      return vi;
  }
  </code></pre>
  
  <p>What's important here is what's going on in the <code>onClick</code> method. I would like to have an item parameter, but this is not possible for this OnClickListener. It's possible for normal listviews, I know that.</p>
  
  <p>So - how can I determine which item is clicked?</p>
  
  <p>PS: I've tried to think of using some sort of <code>vi.setTag(&lt;&lt;number&gt;&gt;);</code>, but I don't see how this can be done without having the same tag set for all items of the listview.</p>