title: MainActivity can't find ListView with id of android.R.id.list, but it's there
body: <p>I was following <a href="http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/" rel="nofollow"><strong>this tutorial</strong></a>. </p>
  
  <p>I've modified it to my app's needs, such as no <strong>CRUD</strong> functionality and no main menu - I just want to list all the items during the main activity that gets executed when the app is launched.</p>
  
  <p>Code seems to have no errors, but running it gives me: <code>Unfortunately, MyFirstApp has stopped</code> in the VM.</p>
  
  <p><strong>LogCat</strong> gives me this:</p>
  
  <blockquote>
    <p>E/AndroidRuntime(910): java.lang.RuntimeException: Unable to start
    activity
    ComponentInfo{com.example.myfirstproject/com.example.myfirstproject.MainActivity}:
    java.lang.RuntimeException: Your content must have a ListView whose id
    attribute is 'android.R.id.list'</p>
  </blockquote>
  
  <p>What do? I've checked my .xml layouts and made the changes, but the app still crashes.</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>package com.example.myfirstproject;
  
  //imports
  
  public class MainActivity extends ListActivity implements OnItemClickListener {
  
      // Progress Dialog
      private ProgressDialog pDialog;
  
      // Creating JSON Parser object
      JSONParser jParser = new JSONParser();
  
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; carsList;
  
      // url to get all products list
      private static String url_all_cars = "http://localhost/webservice/get_all_cars.php";
  
      // JSON Node names
      private static final String TAG_SUCCESS = "success";
      private static final String TAG_CARS = "cars";
      private static final String TAG_NAME = "name";
  
      // products JSONArray
      JSONArray cars = null;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          // Hashmap for ListView
          carsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
          // Loading products in Background Thread
          new LoadAllcars().execute();
  
          // Get listview
          ListView lv = getListView();
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.activity_main, menu);
          return true;
      }
  
      /**
       * Background Async Task to Load all product by making HTTP Request
       * */
      class LoadAllcars extends AsyncTask&lt;String, String, String&gt; {
  
          /**
           * Before starting background thread Show Progress Dialog
           * */
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              pDialog = new ProgressDialog(MainActivity.this);
              pDialog.setMessage("Loading cars. Please wait...");
              pDialog.setIndeterminate(false);
              pDialog.setCancelable(false);
              pDialog.show();
          }
  
          /**
           * getting All products from url
           * */
          protected String doInBackground(String... args) {
              // Building Parameters
              List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
              // getting JSON string from URL
              JSONObject json = jParser.makeHttpRequest(url_all_cars, "GET", params);
  
              // Check your log cat for JSON reponse
              Log.d("All cars: ", json.toString());
  
              try {
                  // Checking for SUCCESS TAG
                  int success = json.getInt(TAG_SUCCESS);
  
                  if (success == 1) {
                      // products found
                      // Getting Array of Products
                      cars = json.getJSONArray(TAG_CARS);
  
                      // looping through All Products
                      for (int i = 0; i &lt; cars.length(); i++) {
                          JSONObject c = cars.getJSONObject(i);
  
                          // Storing each json item in variable
                          String title = c.getString(TAG_NAME);
  
                          // creating new HashMap
                          HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                          // adding each child node to HashMap key =&gt; value
                          map.put(TAG_NAME, name);
  
                          // adding HashList to ArrayList
                          carsList.add(map);
                      }
                  } else {
                      // no products found
                      pDialog = new ProgressDialog(MainActivity.this);
                      pDialog.setMessage("No cars found");
                      pDialog.setIndeterminate(false);
                      pDialog.setCancelable(false);
                      pDialog.show();
                  }
              } catch (JSONException e) {
                  e.printStackTrace();
              }
  
              return null;
          }
  
          /**
           * After completing background task Dismiss the progress dialog
           * **/
          protected void onPostExecute(String file_url) {
              // dismiss the dialog after getting all products
              pDialog.dismiss();
              // updating UI from Background Thread
              runOnUiThread(new Runnable() {
                  public void run() {
                      /**
                       * Updating parsed JSON data into ListView
                       * */
                      ListAdapter adapter = new SimpleAdapter(
                              MainActivity.this, carsList,
                              android.R.id.list, new String[] {TAG_NAME},
                              new int[] { R.id.title });
                      // updating listview
                      setListAdapter(adapter);
                  }
              });
  
          }
      }
  }
  </code></pre>
  
  <p><strong>activity_main.xml</strong> (layout for the mainactivity with listview):</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/main_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
      &lt;ListView
          android:id="@+id/list"
          android:layout_width="fill_parent"
          android:layout_height="0dp"
          android:layout_weight="1" &gt;
      &lt;/ListView&gt;   
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>list_item.xml</strong> (layout for individual list items):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical" &gt;
  
      &lt;!-- Name Label --&gt;
      &lt;TextView
          android:id="@+id/name"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:paddingTop="6dip"
          android:paddingLeft="6dip"
          android:textSize="17dip"
          android:textStyle="bold" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>