title: Making a clickable image to open another activity
body: <p>Here i practice some tutorial of making gridview with auto resize image. i'm adopted this <a href="https://stackoverflow.com/questions/15261088/gridview-with-two-columns-and-auto-resized-images">tutorial</a> to my activity. what i'm gonna do next is how to make the image clickable. so that when users clicked on each image it goes to some class/activity.</p>
  
  <p>Here is several code from the program I experimented :</p>
  
  <p><strong>activity_main.xml</strong> to throw a gridview into layout,stretch mode and column width :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  &gt;
  &lt;GridView
      android:id="@+id/gridview"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:verticalSpacing="5dp"
      android:horizontalSpacing="5dp"
      android:stretchMode="columnWidth"
      android:numColumns="2" 
      /&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p><strong>MainActivity.java</strong> custom ImageView that maintains its aspect ratio:</p>
  
  <pre><code>public class MainActivity extends ImageView {
  public MainActivity(Context context) {
      super(context);
  }
  
  public MainActivity(Context context, AttributeSet attrs) {
      super(context, attrs);
  }
  
  public MainActivity(Context context, AttributeSet attrs, int defStyle) {
      super(context, attrs, defStyle);
  }
  
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
      setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth()); //Snap to width
  }
  }
  </code></pre>
  
  <p>This is a layout for a grid item :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;com.example.conversa.MainActivity
      android:id="@+id/picture"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:scaleType="centerCrop"
      /&gt;
  &lt;TextView
      android:id="@+id/text"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:paddingLeft="10dp"
      android:paddingRight="10dp"
      android:paddingTop="15dp"
      android:paddingBottom="15dp"
      android:layout_gravity="bottom"
      android:textColor="@android:color/white"
      android:background="#55000000"
      /&gt;
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>This is an adapter for gridview :</p>
  
  <pre><code>public 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("Conversation 1",       R.drawable.pic1));
      items.add(new Item("Conversation 2",   R.drawable.pic2));
      items.add(new Item("Conversation 3", R.drawable.pic3));
      items.add(new Item("Conversation 4",      R.drawable.pic4));
      items.add(new Item("Conversation 5",     R.drawable.pic5));
      items.add(new Item("Conversation 6",      R.drawable.pic6));
      items.add(new Item("Conversation 7",       R.drawable.pic7));
      items.add(new Item("Conversation 8",     R.drawable.pic8));
      items.add(new Item("Conversation 9",      R.drawable.pic9));
      items.add(new Item("Conversation 10",       R.drawable.pic10));
  }
  
  @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.gridimage, 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>And this is where the adapter set into gridview :</p>
  
  <pre><code>public class Gridpiw extends Activity {
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      GridView gridView = (GridView)findViewById(R.id.gridview);
      gridView.setAdapter(new MyAdapter(this));
  }
  
  }
  </code></pre>
  
  <p>What should I add or maybe modify so that the image can be clicked to show new activity?</p>