title: how to display position based image for following code?
body: <p>I have the following code. When I click on an image in grid view that particular image should display in another activity. How can I do that?</p>
  
  <p>This is my Activity class::</p>
  
  <pre><code>public class ProductsActivity extends Activity {
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.grid_view);
  
      GridView gridView = (GridView) findViewById(R.id.gridview);
      gridView.setAdapter(new MyAdapter(this));
      gridView.setOnItemClickListener(new AdapterView.OnItemClickListener()
      {
          public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id)
          {
              // this 'mActivity' parameter is Activity object, you can send the current activity.
              Intent i = new Intent(getApplicationContext(), MobileDisplayActivity.class);
              i.putExtra("positionId",position);
              startActivity(i);
          }
      });
  }
  </code></pre>
  
  <p>How do I can change my adapter class to achieve my requirement. Ithink the problem is in <code>getView()</code>.</p>
  
  <pre><code>this is my adapter class:
      private class MyAdapter extends BaseAdapter
  {
      private List&lt;Item&gt; items = new ArrayList&lt;Item&gt;();
      private LayoutInflater inflater;
  
      public MyAdapter(Context context)
      {
          inflater = LayoutInflater.from(context);
  
          items.add(new Item("Image 1", R.drawable.ic_image4));
          items.add(new Item("Image 2", R.drawable.ic_image5));
          items.add(new Item("Image 3", R.drawable.ic_image4));
          items.add(new Item("Image 4", R.drawable.ic_image5));
          items.add(new Item("Image 5", R.drawable.ic_image4));
      }
  
      @Override
      public int getCount() {
          return items.size();
      }
  
      @Override
      public Object getItem(int i)
      {
          return items.get(i);
      }
  
      @Override
      public long getItemId(int i)
      {
          return items.get(i).drawableId;
      }
  
      @Override
      public View getView(int i, View view, ViewGroup viewGroup)
      {
          View v = view;
          ImageView picture;
          TextView name;
  
          if(v == null)
          {
              v = inflater.inflate(R.layout.row_grid, viewGroup, false);
              v.setTag(R.id.picture, v.findViewById(R.id.picture));
              v.setTag(R.id.text, v.findViewById(R.id.text));
          }
  
          picture = (ImageView)v.getTag(R.id.picture);
          name = (TextView)v.getTag(R.id.text);
  
          Item item = (Item)getItem(i);
  
          picture.setImageResource(item.drawableId);
          name.setText(item.name);
  
          return v;
      }
  
      private class Item
      {
          final String name;
          final int drawableId;
  
          Item(String name, int drawableId)
          {
              this.name = name;
              this.drawableId = drawableId;
          }
      }
  }
  </code></pre>
  
  <p>}</p>