android - listview is not updating with notifydataSetChanged -


my listview not updating data retrieved after first 20 items.

i checked multiple times if data not passed json, is, listview not updating added data.

here part of code:

@override public void ongetdata(jsonobject obj) {     serie[] serieslist;     if (obj != null) {         if (pagenumber == 1) {             series = serie.serielistfromjson(this, jsonhandling                     .getinstance().getjsonarrayseriefromurltmdb(obj));             serieslist = series.toarray(new serie[series.size()]);             adapter = new searchcustomadapter(this, serieslist);             lvsearch = (listview) findviewbyid(r.id.lvsearch);             lvsearch.setadapter(adapter);             lvsearch.setonscrolllistener(this);         } else {              try {                 toast.maketext(this, "obj ?"+obj.tostring(1), toast.length_long).show();             } catch (jsonexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }             //adapter.clear(); getting unsupportedmethod exeption             series.addall(serie.serielistfromjson(this, jsonhandling                     .getinstance().getjsonarrayseriefromurltmdb(obj)));             serieslist = series.toarray(new serie[series.size()]);             adapter.notifydatasetchanged();         }     }     if (obj == null) {         toast.maketext(this, "obj null", toast.length_long).show();         serie serie = new serie("not found", "");         serieslist = new serie[series.size()];         serieslist[0] = serie;         adapter = new searchcustomadapter(this, serieslist);         lvsearch = (listview) findviewbyid(r.id.lvsearch);         lvsearch.setadapter(adapter);     } }  @override public void onscroll(abslistview view, int firstvisibleitem,         int visibleitemcount, int totalitemcount) {         this.currentfirstvisibleitem = firstvisibleitem;         this.currentvisibleitemcount = visibleitemcount;         this.currenttotalitemcount=totalitemcount;   }  @override public void onscrollstatechanged(abslistview view, int scrollstate) {     this.currentscrollstate = scrollstate;      if(( currentfirstvisibleitem+currentvisibleitemcount) == currenttotalitemcount){         this.isscrollcompleted();         adapter.notifydatasetchanged();     }   }  private void isscrollcompleted() {     if (this.currentvisibleitemcount > 0 && this.currentscrollstate == scroll_state_idle) {         pagenumber++;         jsonhandling.getinstance().getjsonfromurl(tvtitel.gettext().tostring(), tvyear.gettext().tostring(), iof, pagenumber);         adapter.notifydatasetchanged();     } 

}

so please tell me did wrong or missed?

edit: added code adjust ments in onscrollstatechange. still not sure why should there , not on data though.

also here per requested searchcustumadapter :

public class searchcustomadapter extends arrayadapter<serie> {  private final context context; private final serie[] values;  public searchcustomadapter(context context, serie[] values) {     super(context, r.layout.search_row_layout, values);     this.context = context;     this.values = values; }  @override public view getview(int position, view convertview, viewgroup parent) {      if(convertview==null)     {     layoutinflater inflater = (layoutinflater) context             .getsystemservice(context.layout_inflater_service);     view rowview = inflater.inflate(r.layout.search_row_layout,             parent, false);      textview textviewtitle = (textview) rowview             .findviewbyid(r.id.searchrowtitle);     textview textviewyear = (textview) rowview             .findviewbyid(r.id.searchrowyear);     textviewtitle.settext(values[position].gettitle());     textviewyear.settext(values[position].getyear());       return rowview;       }     else     {         textview textviewtitle = (textview) convertview                 .findviewbyid(r.id.searchrowtitle);         textview textviewyear = (textview) convertview                 .findviewbyid(r.id.searchrowyear);          textviewtitle.settext(values[position].gettitle());         textviewyear.settext(values[position].getyear());          return convertview;     } } 

}

update 2: changed code on onscrollcompleted have part of code:

            pagenumber++;         jsonhandling.getinstance().getjsonfromurl(tvtitel.gettext().tostring(), tvyear.gettext().tostring(), iof, pagenumber);         series.addall(serie.serielistfromjson(this, jsonhandling.getinstance().getjsonarrayseriefromurltmdb(obj)));                          serieslist = series.toarray(new serie[series.size()]);                 lvsearch.setadapter(new searchcustomadapter(this, serieslist)); 

this work, should not way... right?

in

onscrollstatechanged method notifying list view not changing data 

so try call

ongetdata(jsonobject obj) in onscroll may you. 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -