title: listView dynamic add item
body: <p>I used <code>ListView</code> to dynamic add item,but there is a problem about not Smooth add.
  there are textView and button in my listActivity,Iwant to Press button ,then <code>TextView</code>'s text can auto add to <code>ListView</code>,but i Pressed button, it donot work,unless after i enter content , press "OK"Key ,then Pressed button, <code>TextView's</code> text can auto add to <code>ListView</code>. I donot know why. If I continuous Pressed button, as 3 times, then press "Ok" key, the content</p>
  
  <p>auto add list</p>
  
  <p>View but 3 times.</p>
  
  <pre><code> public class DynamicListItems extends ListActivity {
     private static final String   ITEM_KEY   = "key";
     ArrayList&lt;HashMap&lt;String, String&gt;&gt;   list= new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  private SimpleAdapter   adapter;
  private EditText    newValue;@Override
  public void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.dynamic_list);
      newValue = (EditText) findViewById(R.id.new_value_field);
  
      setListAdapter(new SimpleAdapter(this, list, R.layout.row, new String[] { ITEM_KEY }, new int[] { R.id.list_value }));
      ((ImageButton) findViewById(R.id.button)).setOnClickListener(getBtnClickListener());
  }
  
  private OnClickListener getBtnClickListener() {
      return new OnClickListener() {
          public void onClick(View view) {
              try {
  
                  HashMap&lt;String, String&gt; item = new HashMap&lt;String, String&gt;();
                  item.put(ITEM_KEY, newValue.getText().toString());
                  list.add(item);
  
                  adapter.notifyDataSetChanged();
              } catch (NullPointerException e) {
                  Log.i("[Dynamic Items]", "Tried to add null value");
              }
          }
      };
     }}
  </code></pre>
  
  <p>How to dynamic delete the item ?</p>
  
  <ul>
  <li>dynamic_list.xml only contains listView ,button,textView</li>
  <li>row.xml contains <code>TextView</code></li>
  </ul>