title: Popup image onItemClick from Gallery
body: <p>i am new to android. how to popup the selected image from gallery view.i attached my codings.</p>
  
  <pre><code>public class mygallerycode extends Activity
  {
      Integer[] a={R.drawable.hotel1,R.drawable.hotel2,R.drawable.hotel3};
  
      Gallery gallery;
      ImageView imageview;
  
      public void onCreate(Bundle bb) {
          super.onCreate(bb);
          setContentView(R.layout.mygallery);
          gallery=(Gallery)findViewById(R.id.gallery1);
          gallery.setAdapter(new ImageAdapter(this));
  
          imageview=(ImageView)findViewById(R.id.imageView1);
  
          gallery.setOnItemClickListener(new OnItemClickListener()
          {
          public void onItemClick(AdapterView&lt;?&gt; parent, View v,
          int position, long id)
          {
          Toast.makeText(getBaseContext(),"picture" + (position+1) +"selected",Toast.LENGTH_SHORT).show();
          //imageview.setImageResource(a[position]);
  
  
          }
          });
      }
          class ImageAdapter extends BaseAdapter
          {
  
              private Context context;
              private int itemBackground;
  
              public ImageAdapter(Context c)
              {
                  context = c;
                  //---setting the style---
                  TypedArray ta = obtainStyledAttributes(R.styleable.gallery1);
                  itemBackground = ta.getResourceId(
                  R.styleable.gallery1_android_galleryItemBackground, 1);
                  ta.recycle();
  
              }
  
              @Override
              public int getCount() {
                  // TODO Auto-generated method stub
                  return a.length;
              }
  
              @Override
              public Object getItem(int position) {
                  // TODO Auto-generated method stub
                  return position;
              }
  
              @Override
              public long getItemId(int position) {
                  // TODO Auto-generated method stub
                  return position;
              }
  
              @Override
              public View getView(int position, View convertView,
                      ViewGroup parent) {
                  // TODO Auto-generated method stub
                  ImageView imageView = new ImageView(context);
                  imageView.setImageResource(a[position]);
                  imageView.setScaleType(ImageView.ScaleType.FIT_XY);
                  imageView.setLayoutParams(new Gallery.LayoutParams(150, 120));
                  imageView.setBackgroundResource(itemBackground);
                  return imageView;
              }
  
          }
      }
  </code></pre>