Organizational Research By

Surprising Reserch Topic

remove listview items in android


remove listview items in android  using -'android,android-listview'

Can somebody please give me an example code of removing all ListView items and replacing with new items?

I tried replacing the adapter items without success. My code is

populateList(){

 results //populated arraylist with strings

 ArrayAdapter<String> adapter = new ArrayAdapter<String>(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<String> adapter1 = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, results1);

 listview.setAdapter(adapter1);
 adapter1.notifyDataSetChanged();
 listview.setOnItemClickListener(this);
}


Here repopulateList() method will add to ListView items, but it doesn't remove/replace all ListView items.
    

asked Sep 21, 2015 by sujata naik
0 votes
46 views



Related Hot Questions

7 Answers

0 votes
NULL
answered Sep 21, 2015 by vijayshukla80
0 votes
NULL
answered Sep 21, 2015 by tushar2k6
0 votes
NULL
answered Sep 21, 2015 by vimaldas2005
0 votes
NULL
answered Sep 21, 2015 by ankitarajoria4
0 votes
NULL
answered Sep 21, 2015 by sachin wagh
0 votes
NULL
answered Sep 21, 2015 by deepak07.s
0 votes
NULL
answered Sep 21, 2015 by gauravg.gwl

...