title: Using MatrixCursor and SimpleCursorAdapter in a ListView with text and images
body: <p>I'm having an issue using a <code>MatrixCursor</code> to populate my <code>ListView</code>:</p>
  
  <pre><code>private void fillData() {
      String[] menuCols = new String[] { "icon", "item", "price" };
      int[] to = new int[] { R.id.icon, R.id.item, R.id.price };
  
      MatrixCursor menuCursor = new MatrixCursor(menuCols);
      startManagingCursor(menuCursor);
  
      menuCursor.addRow(new Object[] { R.drawable.chicken_sandwich, "Chicken Sandwich", "$3.99" });
  
      SimpleCursorAdapter menuItems = new SimpleCursorAdapter(
              this, R.layout.menu_row, menuCursor, menuCols, to);
  
      setListAdapter(menuItems);
  }
  </code></pre>
  
  <p>Constructing the <code>SimpleCursorAdapter</code> causes a crash. Even when I tried removing the icon the app still crashed. Here is my <code>menu_row.xml</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;ImageView 
          android:id="@+id/icon"
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content"&gt;
      &lt;/ImageView&gt;
      &lt;TextView 
          android:id="@+id/item" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content"&gt;
      &lt;/TextView&gt;
      &lt;TextView 
          android:id="@+id/price" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content"&gt;
      &lt;/TextView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Edit:</strong> Here is the call stack at the time of the crash:</p>
  
  <pre><code>Thread [&lt;3&gt; main] (Suspended (exception RuntimeException))  
      ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2481  
      ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2497   
      ActivityThread.access$2200(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 119 
      ActivityThread$H.handleMessage(Message) line: 1848  
      ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
      Looper.loop() line: 123 
      ActivityThread.main(String[]) line: 4338    
      Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
      Method.invoke(Object, Object...) line: 521  
      ZygoteInit$MethodAndArgsCaller.run() line: 860  
      ZygoteInit.main(String[]) line: 618 
      NativeStart.main(String[]) line: not available [native method]  
  </code></pre>
  
  <p><strong>SOLUTION:</strong></p>
  
  <p>I found the problem and the solution is in my answer below.</p>