title: GridView crashing
body: <p>I want to create a <code>GridView</code> and fill it with numbers. I created my <code>GridView</code>, and I filled it and then I built it successfully, but when I ran it, the application crashed and I got the following error <em>"Unfortunately,… has stopped ".</em></p>
  
  <p>Layout:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;GridLayout
      android:id="@+id/gridView1"
      android:numColumns="auto_fit"
      android:gravity="center"
      android:columnWidth="50dp"
      android:stretchMode="columnWidth"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" &gt; 
      &lt;/GridLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><code>main.java</code>:</p>
  
  <pre><code>package main.java;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.view.*;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ArrayAdapter;
  import android.widget.GridView;
  import android.widget.TextView;
  import android.widget.Toast;
  
  
  public class MainActivity extends Activity {
  
      static final String[] numbers = new String[] { 
          "A", "B", "C", "D", "E",
          "F", "G", "H", "I", "J",
          "K", "L", "M", "N", "O",
          "P", "Q", "R", "S", "T",
          "U", "V", "W", "X", "Y", "Z"};
  
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
  
  
          GridView g = (GridView) findViewById(R.id.gridView1);
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1 , numbers);
          g.setAdapter(adapter);
  
          g.setOnItemClickListener(new OnItemClickListener() {
              public void onItemClick(AdapterView&lt;?&gt; parent, View v,
                  int position, long id) {
                 Toast.makeText(getApplicationContext(),
                  ((TextView) v).getText(), Toast.LENGTH_SHORT).show();
              }
  
          });
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.activity_main, menu);
          return true;
      }
  
  
  }
  </code></pre>
  
  <p>I copied the tutorials <a href="http://www.mkyong.com/android/android-gridview-example/" rel="nofollow">here</a>.</p>
  
  <p>Here are logs:</p>
  
  <pre><code>08-07 11:36:37.858: E/Trace(614): error opening trace file: No such file or directory (2)
  08-07 11:36:38.587: D/AndroidRuntime(614): Shutting down VM
  08-07 11:36:38.587: W/dalvikvm(614): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
  08-07 11:36:38.597: E/AndroidRuntime(614): FATAL EXCEPTION: main
  08-07 11:36:38.597: E/AndroidRuntime(614): java.lang.RuntimeException: Unable to start activity ComponentInfo{main.java/main.java.MainActivity}: java.lang.ClassCastException: android.widget.GridLayout cannot be cast to android.widget.GridView
  08-07 11:36:38.597: E/AndroidRuntime(614):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at android.os.Handler.dispatchMessage(Handler.java:99)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at android.os.Looper.loop(Looper.java:137)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at android.app.ActivityThread.main(ActivityThread.java:4745)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at java.lang.reflect.Method.invokeNative(Native Method)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at java.lang.reflect.Method.invoke(Method.java:511)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at dalvik.system.NativeStart.main(Native Method)
  08-07 11:36:38.597: E/AndroidRuntime(614): Caused by: java.lang.ClassCastException: android.widget.GridLayout cannot be cast to android.widget.GridView
  08-07 11:36:38.597: E/AndroidRuntime(614):  at main.java.MainActivity.onCreate(MainActivity.java:32)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at android.app.Activity.performCreate(Activity.java:5008)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  08-07 11:36:38.597: E/AndroidRuntime(614):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
  08-07 11:36:38.597: E/AndroidRuntime(614):  ... 11 more
  08-07 11:36:42.507: I/Process(614): Sending signal. PID: 614 SIG: 9
  </code></pre>