title: Remove ListView items in Android
body: <p>Can somebody please give me an example code of removing all ListView items and replacing with new items?</p>
  
  <p>I tried replacing the adapter items without success. My code is</p>
  
  <pre><code>populateList(){
  
   results //populated arraylist with strings
  
   ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
                  android.R.layout.simple_list_item_1, results);
  
   listview.setAdapter(adapter);
   adapter.notifyDataSetChanged();
   listview.setOnItemClickListener(this);
  
  }
  
  // now populating list again
  
  repopulateList(){
  
   results1 //populated arraylist with strings
  
   ArrayAdapter&lt;String&gt; adapter1 = new ArrayAdapter&lt;String&gt;(this,
                  android.R.layout.simple_list_item_1, results1);
  
   listview.setAdapter(adapter1);
   adapter1.notifyDataSetChanged();
   listview.setOnItemClickListener(this);
  }
  </code></pre>
  
  <p>Here <code>repopulateList()</code> method will add to ListView items, but it doesn't remove/replace all ListView items.</p>