android - ListView duplicate content after notifyDataSetChanged -


i'm designing listview powered custom adapter. in fragment, assign adapter in onactivitycreated() :

private list<datas> values = new arraylist<datas>(); private myadapter adapter;  @override public void onactivitycreated(bundle savedinstancestate) {     adapter = new myadapter(values, getactivity());     listview.setadapter(adapter);     .....} 

later in app, load datas internet, , put values :

while(loop on every datas items) {     values.add(new datas(...)); } adapter.notifydatasetchange(); 

when user scrolls down, load more items (thanks onscrolllistener, record), previous snippet called again. basically, before update scrolling, have : a, b, c, d, e, f. after update, have a, b, c, d e, f, a, b, c, d e, f, g, h, i, j, k ...

the first values appears twice, instate of append @ end.

thanks reading , :)

edit : re-considered class, new adapter , everything. now, without rational explanation, works. anyway ;)

that's because downloading existing values , adding them again... should clear list before adding, or (better) avoid downloading data present in list


Comments

Popular posts from this blog

android - Automated my builds -

how to proxy from https to http with lighttpd -

python - Flask migration error -