Yea, call adapter1.clear() and then you can add your new items to it,
one by one, by calling adapter1.add(). When you're done messing with
it, call adapter1.notifyDataSetChanged() and your ListView will
update.


On Apr 1, 12:37 am, Alexander Balasanov <[email protected]>
wrote:
> Do not use a new istance of adapter for depopulate view,instead call clear in 
> existing adapter
>
>
>
> kavitha <[email protected]> wrote:
> >Hi all,,
>
> >Can somebody please give me an example code of removing all ListView items
> >and replacing with new items.
>
> >I tried replacing the adapter items.Still no results.
>
> >my code is
>
> >at first i am calling
>
> >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 replpulateList() method will add to listview items. It doent
> >remove/replace all listview items.
>
> >Please Help.
>
> >Thanks
> >Kavitha
>
> >--
> >You received this message because you are subscribed to the Google
> >Groups "Android Developers" group.
> >To post to this group, send email to [email protected]
> >To unsubscribe from this group, send email to
> >[email protected]
> >For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> >To unsubscribe, reply using "remove me" as the subject.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to