title: Add user input into a ListView on button click
body: <p>I am trying to make a TO DO LIST.  I have a EditText, Button, and ListView.  On button click I want to add, what I typed into the EditText into a ListView.</p>
  
  <p>main_activity.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  &lt;EditText
      android:id="@+id/editText"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:hint="Enter task"
      android:textSize="24dp"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true" /&gt;
  &lt;Button
      android:id="@+id/addTaskBtn"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="Add Task"
      android:layout_below="@+id/editText"
      android:layout_alignParentLeft="true" /&gt;
  &lt;TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="        Task"
      android:id="@+id/header"
      android:layout_below="@+id/addTaskBtn"
      android:background="#5e5e5e"
      android:textColor="#FFFFFF"
      android:textSize="14dp"/&gt;
  &lt;ListView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/list"
      android:layout_below="@+id/header"
      android:layout_centerHorizontal="true" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Main_ToDoList.java</p>
  
  <pre><code>package com.example.todolist;
  import android.app.Activity;
  import android.app.ListActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.ListView;
  
  import java.util.ArrayList;
  
  public class Main_ToDoList extends Activity implements OnClickListener
  {
  private Button btnAdd;
  private EditText et;
  private ListView lv;
  ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
  ArrayAdapter&lt;String&gt; adapter;
  
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main_activity);
  
      btnAdd = (Button)findViewById(R.id.addTaskBtn);
      btnAdd.setOnClickListener(this);
      et = (EditText)findViewById(R.id.editText);
      adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_expandable_list_item_1, list);
      lv.setAdapter(adapter);
  }
  public void onClick(View v)
  {
      String input = et.getText().toString();
      if(input.length() &gt; 0)
      {
          list.add(input);
          adapter.notifyDataSetChanged();
      }
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu)
  {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main__to_do_list, menu);
      return true;
  }   
  }
  </code></pre>
  
  <p>The code doesn't work, new to android developing, and just trying to create a simple To Do List.  Thanks for your help!</p>