title: BaseAdapter and ContextMenu
body: <p>Hello stackoverflow community, </p>
  
  <p>Basically, i have gallery displaying some images using a gridView + imageView</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent" android:layout_height="fill_parent"&gt;
  
      &lt;GridView android:id="@+id/PhoneImageGrid"
              android:layout_width="fill_parent" android:layout_height="fill_parent"
              android:numColumns="auto_fit" android:verticalSpacing="12dp"
              android:horizontalSpacing="12dp" android:columnWidth="90dp"
              android:stretchMode="columnWidth" android:gravity="center" /&gt;
  
          &lt;ImageView android:id="@+id/thumbImage" android:layout_width="wrap_content"
              android:layout_height="wrap_content" android:layout_centerInParent="true" 
  
              android:scaleType="centerCrop"
              /&gt;
  </code></pre>
  
  <p></p>
  
  <p>I would like to use setOnLongClick for each imageView displayed by the adapter.
  This works well, however, when clicking long on the imageView, i would like to display a ContextMenu with some items ( i.e, you long click on an imageView, a contextMenu is displayed with some items : Image information, send this image ...).
  Unfortunatly, i can't figure out how to inflate this menu in the adapter.(Probably not the good way to do it )</p>
  
  <p><strong>I have the following lines in my main activity</strong></p>
  
  <pre><code>_adapter = new ImageAdapter(activity,storedObjects.getAlbums());
  imagegrid.setAdapter(_adapter);
  </code></pre>
  
  <p><strong>My adapter ( some useless lines removed )</strong></p>
  
  <pre><code>  public class ImageAdapter extends BaseAdapter {
  
      private Albums albums;
      private Context context;
      private LayoutInflater inflater;     
  
  
  
      public ImageAdapter(Context context, Albums albums) {
  
          this.albums = albums;
          this.context = context;
          inflater = (LayoutInflater)context.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
          if(albums.getAlbumsListSize() == 0) {
              Toast.makeText(context, "There is no album to display", Toast.LENGTH_LONG).show();
          }
      }
  
  
  
  
      public View getView(final int position, View view, ViewGroup parent) {
  
          ViewHolder holder;
  
          if (view == null) {       
              holder = new ViewHolder();       
              view = inflater.inflate(R.layout.galleryitem, null);       
              holder.imageview = (ImageView) view.findViewById(R.id.thumbImage);        
              holder.checkbox = (CheckBox) view.findViewById(R.id.itemCheckBox); 
              holder.textview = (TextView) view.findViewById(R.id.album_name); 
              holder.checkbox.setChecked(true);
              //Bitmap loadingBM = BitmapFactory.decodeResource(context.getResources(),R.drawable.loading_image);
              //holder.imageview.setImageBitmap(loadingBM);
              view.setTag(holder);
          }
  
          else {
              holder = (ViewHolder) view.getTag();
          }
  
          holder.imageview.setClickable(true);
  
  
          holder.imageview.setOnLongClickListener(new OnLongClickListener() {
  
  
              public boolean onLongClick(View v) {
  
                  Log.v(TAG,"onLongClick ok !");
                  return false;
              }
  
          });
  
  
          imageDownloader.download(this.context, albums.getAllAlbums().get(position).getThumbnailUri(), holder.imageview);            
  
  
          return view;
      }
  </code></pre>
  
  <p>Questions :</p>
  
  <ol>
  <li>setOnLongClickListener works properly, when i click on an image, my Log is displayed in logcat, however, how to create a menu for each imageView ?</li>
  </ol>
  
  <p>Apparently, i can only override onCreateContextMenu in my main activity. I guess i could pass each ImageView to onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) but how ? </p>
  
  <p>I would be really grateful if you could help me out with this.</p>
  
  <p>Thank you very much</p>
  
  <p>Florent Valdelievre</p>