title: IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
body: <p>I ran my code once and it was fine, I ran it again and now it crashes every time. LogCat gave me this:</p>
  
  <pre><code>04-11 03:15:57.293: D/dalvikvm(344): GC_EXTERNAL_ALLOC freed 68K, 52% free 2588K/5379K,   external 1907K/2137K, paused 65ms
  04-11 03:15:57.497: E/ArrayAdapter(344): You must supply a resource ID for a TextView
  04-11 03:15:57.497: D/AndroidRuntime(344): Shutting down VM
  04-11 03:15:57.497: W/dalvikvm(344): threadid=1: thread exiting with uncaught exception (group=0x40015560)
  04-11 03:15:57.573: E/AndroidRuntime(344): FATAL EXCEPTION: main
  04-11 03:15:57.573: E/AndroidRuntime(344): java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:347)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.AbsListView.obtainView(AbsListView.java:1430)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.ListView.measureHeightOfChildren(ListView.java:1216)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.ListView.onMeasure(ListView.java:1127)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.view.View.measure(View.java:8313)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.RelativeLayout.measureChild(RelativeLayout.java:566)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:381)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.view.View.measure(View.java:8313)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.view.View.measure(View.java:8313)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:581)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:365)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.view.View.measure(View.java:8313)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.view.View.measure(View.java:8313)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.view.View.measure(View.java:8313)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.view.View.measure(View.java:8313)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.view.ViewRoot.performTraversals(ViewRoot.java:839)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.os.Handler.dispatchMessage(Handler.java:99)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.os.Looper.loop(Looper.java:123)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.app.ActivityThread.main(ActivityThread.java:3683)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at java.lang.reflect.Method.invokeNative(Native Method)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at java.lang.reflect.Method.invoke(Method.java:507)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  04-11 03:15:57.573: E/AndroidRuntime(344):  at dalvik.system.NativeStart.main(Native Method)
  04-11 03:15:57.573: E/AndroidRuntime(344): Caused by: java.lang.ClassCastException: android.widget.RelativeLayout
  04-11 03:15:57.573: E/AndroidRuntime(344):  at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:340)
  04-11 03:15:57.573: E/AndroidRuntime(344):  ... 35 more
  04-11 03:17:31.694: I/Process(344): Sending signal. PID: 344 SIG: 9
  </code></pre>
  
  <p>I have three activities:</p>
  
  <pre><code>package com.androidbook.triviaquiz;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.TextView;
  
  public class QuizMenuActivity extends QuizActivity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.menu);
  
          ListView menuList = (ListView) findViewById(R.id.listView1);
  
          String[] items = { getResources().getString(R.string.itemplay),
                  getResources().getString(R.string.itemscores),
                  getResources().getString(R.string.itemsettings),
                  getResources().getString(R.string.itemhelp) };
          ArrayAdapter&lt;String&gt; adapt = new ArrayAdapter&lt;String&gt;(this, R.layout.menu, items);
          menuList.setAdapter(adapt);
  
          menuList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
              public void onItemClick(AdapterView&lt;?&gt; parent, View itemClicked, int position, long id) {
  
                  // Note: if the list was built "by hand" the id could be used.
                  // As-is, though, each item has the same id
  
                  TextView textView = (TextView) itemClicked;
                  String strText = textView.getText().toString();
  
                  if (strText.equalsIgnoreCase(getResources().getString(R.string.itemplay))) {
                      // Launch the Game Activity
                      startActivity(new Intent(QuizMenuActivity.this, QuizGameActivity.class));
                  } else if (strText.equalsIgnoreCase(getResources().getString(R.string.itemhelp))) {
                      // Launch the Help Activity
                      startActivity(new Intent(QuizMenuActivity.this, QuizHelpActivity.class));
                  } else if (strText.equalsIgnoreCase(getResources().getString(R.string.itemsettings))) {
                      // Launch the Settings Activity
                      startActivity(new Intent(QuizMenuActivity.this, QuizSettingsActivity.class));
                  } else if (strText.equalsIgnoreCase(getResources().getString(R.string.itemscores))) {
                      // Launch the Scores Activity
                      startActivity(new Intent(QuizMenuActivity.this, QuizScoresActivity.class));
                  }
  
              }
          });
  
  
      }
  
  
  }
  </code></pre>
  
  <p>this one:</p>
  
  <pre><code>package com.androidbook.triviaquiz;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.TextView;
  
  public class QuizMenuActivity extends QuizActivity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.menu);
  
          ListView menuList = (ListView) findViewById(R.id.listView1);
  
          String[] items = { getResources().getString(R.string.itemplay),
                  getResources().getString(R.string.itemscores),
                  getResources().getString(R.string.itemsettings),
                  getResources().getString(R.string.itemhelp) };
          ArrayAdapter&lt;String&gt; adapt = new ArrayAdapter&lt;String&gt;(this, R.layout.menu, items);
          menuList.setAdapter(adapt);
  
          menuList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
              public void onItemClick(AdapterView&lt;?&gt; parent, View itemClicked, int position, long id) {
  
                  // Note: if the list was built "by hand" the id could be used.
                  // As-is, though, each item has the same id
  
                  TextView textView = (TextView) itemClicked;
                  String strText = textView.getText().toString();
  
                  if (strText.equalsIgnoreCase(getResources().getString(R.string.itemplay))) {
                      // Launch the Game Activity
                      startActivity(new Intent(QuizMenuActivity.this, QuizGameActivity.class));
                  } else if (strText.equalsIgnoreCase(getResources().getString(R.string.itemhelp))) {
                      // Launch the Help Activity
                      startActivity(new Intent(QuizMenuActivity.this, QuizHelpActivity.class));
                  } else if (strText.equalsIgnoreCase(getResources().getString(R.string.itemsettings))) {
                      // Launch the Settings Activity
                      startActivity(new Intent(QuizMenuActivity.this, QuizSettingsActivity.class));
                  } else if (strText.equalsIgnoreCase(getResources().getString(R.string.itemscores))) {
                      // Launch the Scores Activity
                      startActivity(new Intent(QuizMenuActivity.this, QuizScoresActivity.class));
                  }
  
              }
          });
  
  
      }
  
  
  }
  </code></pre>
  
  <p>and this one:</p>
  
  <pre><code>package com.androidbook.triviaquiz;
  
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  
  public class QuizGameActivity extends QuizActivity {
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.game);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          super.onCreateOptionsMenu(menu);
          getMenuInflater().inflate(R.menu.gameoptions, menu);
          menu.findItem(R.id.help_menu_item).setIntent(new Intent(this, QuizHelpActivity.class));
          menu.findItem(R.id.settings_menu_item).setIntent(new Intent(this, QuizSettingsActivity.class));
          return true;
      }
       @Override
         public boolean onOptionsItemSelected(MenuItem item) {
            super.onOptionsItemSelected(item);
            startActivity(item.getIntent());
             return true;
          }
  }
  </code></pre>
  
  <p>Can someone tell me what is wrong with this code? Like I said before, all I did was restart it. Are these the only things that you need to figure it out, maybe the manifest?  </p>
  
  <p>EDIT: Res/layout/menu</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"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".QuizSplashActivity" &gt;
  
      &lt;LinearLayout
          android:id="@+id/linearLayout1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentRight="true"
          android:layout_alignParentTop="true"
          android:background="@drawable/th"
          android:orientation="vertical" &gt;
  
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="50dp"
              android:background="#000000" &gt;
  
              &lt;ImageView
                  android:id="@+id/ImageView2"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentTop="true"
                  android:src="@drawable/quizicon" /&gt;
  
              &lt;TextView
                  android:id="@+id/textView1"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentTop="true"
                  android:layout_centerHorizontal="true"
                  android:text="MAIN MENU"
                  android:textColor="#ffffff"
                  android:textSize="20pt" /&gt;
  
              &lt;ImageView
                  android:id="@+id/imageView1"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentRight="true"
                  android:layout_alignParentTop="true"
                  android:src="@drawable/quizicon" /&gt;
          &lt;/RelativeLayout&gt;
  
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content" &gt;
  
              &lt;ListView
                  android:id="@+id/listView1"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_alignParentTop="true"
                  android:gravity="center"&gt;
  
  
  
              &lt;/ListView&gt;
  
          &lt;/RelativeLayout&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>