title: adding ListView items by clicking on a button
body: <p>after some days of trying, searching and again trying i want to ask u guys for help.</p>
  
  <p>I want to fill a ListView by clicking on a button with random user input items.</p>
  
  <p>here is a example picture of my activity_main.xml</p>
  
  <p><a href="http://s1.directupload.net/file/d/3109/x6qnnj5s_png.htm" rel="nofollow">http://s1.directupload.net/file/d/3109/x6qnnj5s_png.htm</a></p>
  
  <p>i Tried severel code snippets from here and other sites but every time my Virtual device says The application test_1 (process com.example.test_1) has stopped unexpectedly. Pleasy try again.</p>
  
  <p>my current code is:</p>
  
  <p><b> activity_main.xml </b></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"
  tools:context=".MainActivity" &gt;
  
  &lt;ListView
      android:id="@+id/tPlanView"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_above="@+id/addTplan" &gt;
  &lt;/ListView&gt;
  
  &lt;Button
      android:id="@+id/addTplan"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_alignParentLeft="true"
      android:layout_alignParentRight="true"
      android:text="Button" /&gt;
  </code></pre>
  
  <p></p>
  
  <p><b>list_item.xml</b></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;EditText
      android:id="@+id/textIn"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true" /&gt;
  &lt;TextView 
      android:id="@+id/textOut"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
  
      /&gt;
  </code></pre>
  
  <p></p>
  
  <p><b>MainActivity.java</b></p>
  
  <pre><code>public class MainActivity extends ListActivity {
  
  /** Items entered by the user is stored in this ArrayList variable */
  ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
  
  /** Declaring an ArrayAdapter to set items to ListView */
  ArrayAdapter&lt;String&gt; adapter;
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      /** Setting a custom layout for the list activity */
      setContentView(R.layout.activity_main);
  
      /** Reference to the button of the layout main.xml */
      Button btn = (Button) findViewById(R.id.addTplan);
  
      /** Defining the ArrayAdapter to set items to ListView */
      adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, list);
  
      /** Setting the event listener for the add button */
      btn.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              EditText edit = (EditText) findViewById(R.id.textIn);
              list.add(edit.getText().toString());
              edit.setText("");
              adapter.notifyDataSetChanged();
  
          }
      });
  
      /** Setting the adapter to the ListView */
      setListAdapter(adapter);
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.activity_main, menu);
      return true;
  }
  </code></pre>
  
  <p>im glad for any help.
  thanks in advance allready :-)</p>
  
  <p><b> ------- UPDATE ------ </b></p>
  
  <p>logcat</p>
  
  <pre><code>    12-19 22:45:02.854: D/AndroidRuntime(330): Shutting down VM
  12-19 22:45:02.854: W/dalvikvm(330): threadid=1: thread exiting with uncaught exception (group=0x40015560)
  12-19 22:45:02.864: E/AndroidRuntime(330): FATAL EXCEPTION: main
  12-19 22:45:02.864: E/AndroidRuntime(330): java.lang.RuntimeException: Unable to start activity ComponentInfo{ de.example.test_1test_1/ de.example.test_1.MainActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
  12-19 22:45:02.864: E/AndroidRuntime(330):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at android.os.Handler.dispatchMessage(Handler.java:99)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at android.os.Looper.loop(Looper.java:123)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at android.app.ActivityThread.main(ActivityThread.java:3683)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at java.lang.reflect.Method.invokeNative(Native Method)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at java.lang.reflect.Method.invoke(Method.java:507)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at dalvik.system.NativeStart.main(Native Method)
  12-19 22:45:02.864: E/AndroidRuntime(330): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
  12-19 22:45:02.864: E/AndroidRuntime(330):  at android.app.ListActivity.onContentChanged(ListActivity.java:243)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:210)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at android.app.Activity.setContentView(Activity.java:1657)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at  de.example.test_1.MainActivity.onCreate(MainActivity.java:33)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  12-19 22:45:02.864: E/AndroidRuntime(330):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  12-19 22:45:02.864: E/AndroidRuntime(330):  ... 11 more
  12-19 22:45:05.964: I/Process(330): Sending signal. PID: 330 SIG: 9
  </code></pre>