title: Android Gallery and Adapters
body: <p>I have images that I want them to be in a gallery using an adapter to select each and it will be drawn using canvas, I watched many tutorials and I made my code, now I don't know where is the wrong I'm making</p>
  
  <pre><code>Gallery g;
  ImageAdapter imageAdapter;
  
         Gallery g = (Gallery) findViewById(R.id.gBitmap);
         imageAdapter = new ImageAdapter(this);
         g.setAdapter(imageAdapter);
  
      //selected Bitmap from gallery
         g.setOnItemClickListener(new OnItemClickListener() {
             public void onItemClick(AdapterView&lt;?&gt; parent,
                 View v, int position, long id) {
                 applyBitmap(position);
             }
         });
      }
  
      public class ImageAdapter extends BaseAdapter {
         int mGalleryItemBackground;
         private Context mContext;
  
         private Integer[] mImageIds = {
                 R.drawable.first,
                 R.drawable.second,
                 R.drawable.fifth,
                 R.drawable.third,
                 R.drawable.fourth,
  
         public ImageAdapter(Context c) {
             mContext = c;
         }
  
         public int getCount() {
             return mImageIds.length;
         }
  
         public Object getItem(int position) {
             return position;
         }
  
         public long getItemId(int position) {
             return position;
         }
  
         public View getView(int position,
             View convertView, ViewGroup parent) {
              return iv;
         }
      }
  
      public static void Bitmap(int position) {
          BitmapFactory.Options opt = new BitmapFactory.Options();
          opt.inScaled = true;
          opt.inPurgeable = true;
              opt.inInputShareable = true;
              Bitmap brightBitmap = BitmapFactory.decodeResource(null, position, opt);
          iv.setImageBitmap(brightBitmap);
  
  
      }
  </code></pre>
  
  <p>I need to get the selected <code>mImageIds</code> to use my function called <code>Bitmap</code></p>