title: How to get the position of an Item from a PopupMenu in a custom ListView
body: <p>Here's the problem: I've got a custom ArrayAdapter (overriden getView). Each item has got</p>
  
  <ul>
  <li>2 ImageView</li>
  <li>2 EditText</li>
  </ul>
  
  <p>One of those ImageView is clickable and enables a PopupMenu, so I've got a little PopupMenu for each item of the list. Now, for that menu I need some parameters from the item to wich is anchored. So, how to pass informations (like position) to the method called from the PopupMenu voice? Attached the xml files.</p>
  
  <p><strong>item_list.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:paddingBottom="5dp"
      android:paddingTop="5dp" &gt;
  
      &lt;ImageView
          android:id="@+id/icon"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center_vertical"
          android:layout_marginRight="6dip"
          android:contentDescription="TODO"
          android:src="@drawable/ic_launcher" /&gt;
  
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical" &gt;
  
          &lt;TextView
              android:id="@+id/firstLine"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:gravity="center_vertical"
              android:maxHeight="60dp"
              android:text="Title"
              android:textSize="16sp" /&gt;
  
          &lt;ImageView
              android:id="@+id/imageView1"
              android:layout_width="25dp"
              android:layout_height="25dp"
              android:layout_alignParentRight="true"
              android:layout_alignParentTop="true"
              android:contentDescription="TODO"
              android:onClick="showMenu"
              android:src="@drawable/abc_ic_menu_moreoverflow_normal_holo_light" /&gt;
  
          &lt;TextView
              android:id="@+id/secondLine"
              android:layout_width="fill_parent"
              android:layout_height="26dip"
              android:layout_alignParentLeft="true"
              android:layout_below="@+id/firstLine"
              android:ellipsize="marquee"
              android:singleLine="true"
              android:text="Author"
              android:textSize="12sp" /&gt;
  
      &lt;/RelativeLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>menu_item.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt;
  
          &lt;item
              android:id="@+id/preview"
              android:onClick="preview"
              android:title="@string/preview"/&gt;
          &lt;item
              android:id="@+id/download"
              android:onClick="download"
              android:title="@string/download"/&gt;
  
      &lt;/menu&gt;
  </code></pre>
  
  <p><strong>CustomArrayAdapter.java</strong></p>
  
  <pre><code>public class CustomArrayAdapter extends ArrayAdapter&lt;Custom&gt;{
  
      private final Context context;
      private final List&lt;Custom&gt; values;
      private final int resource;
      private final ImageCache imgCache = new ImageCache();
  
      public CustomArrayAdapter(Context context, int resource, List&lt;Custom&gt; values) {
          super(context, resource, values);
          this.context = context;
          this.values = values;
          this.resource = resource;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          ViewHolder vh;
          Custom Custom = values.get(position);
          if (convertView == null) {
              vh = new ViewHolder();
              LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = inflater.inflate(resource, parent, false);
              vh.title = (TextView) convertView.findViewById(R.id.firstLine);
              vh.author = (TextView) convertView.findViewById(R.id.secondLine);
              vh.albumImage = (ImageView) convertView.findViewById(R.id.icon);
              convertView.setTag(vh);
          }
          else {
              vh = (ViewHolder)convertView.getTag();
          }
          vh.requestedCustom = Custom;
          vh.title.setText(Custom.getTitle());
          vh.author.setText(Custom.getAuthor());
          String imgUrl = Custom.getImgUrl();
          if (imgUrl != null) {
              imgCache.getImage(Custom, vh);
          }
          else {
              vh.albumImage.setImageResource(R.drawable.no_album);
          }
          return convertView;
      }
  
      // This is a ViewHolder that helps in the view recycling
      public static class ViewHolder {
          public Custom requestedCustom;
          public TextView title;
          public TextView author;
          public ImageView albumImage;
      }
  }
  </code></pre>
  
  <p>"preview" and "download" methods need parameters from the associated list item and I don't know how to get them. Thanks again.</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>It seems that a Contextual Menu should be used instead (right?) but I would like to anchor it to each item as a sort of popup menu that appears. So how can I achieve this?
  For those who don't understand what I want (due to my worst english): Google Play app, popup menu that let you choose between "Install" or "Add to whishlist".</p>