android - Expandable ListView not updating at runtime -


i using asynctask make url connection , send request fatsecret api. api returns json object pass populatelist(jsonarray ja) using onpostexecute(). in method populatelist(), tryin parse json data visible in expandable listview. however, when call listadapter.notifydatasetchanged() listview not updating. @ appreciated. code below:

 public void populatelist(jsonarray ja){      try{         for(int i=0; i<ja.length(); i++){             jsonobject realobj = ja.getjsonobject(i);              fooddatas.add(realobj.getstring("food_description"));             listadapter.notifydatasetchanged();              listdataheader.add(realobj.getstring("food_name"));             listadapter.notifydatasetchanged();              fooddatas.add(realobj.getstring("food_type"));             listadapter.notifydatasetchanged();              listdatachild.put(listdataheader.get(i),fooddatas);             listadapter.notifydatasetchanged();         }     }catch (exception exception) {         log.e("fatsecret error", exception.tostring());         exception.printstacktrace();     } } 

edit:

this custom listadapter being used.

    public class expandablelistadapter extends baseexpandablelistadapter {  private context _context; private list<string> _listdataheader; // header titles // child data in format of header title, child title private hashmap<string, list<string>> _listdatachild;  public expandablelistadapter(context context, list<string> listdataheader,                              hashmap<string, list<string>> listchilddata) {     this._context = context;     this._listdataheader = listdataheader;     this._listdatachild = listchilddata; }  @override public object getchild(int groupposition, int childposititon) {     return this._listdatachild.get(this._listdataheader.get(groupposition))             .get(childposititon); }  @override public long getchildid(int groupposition, int childposition) {     return childposition; }  @override public view getchildview(int groupposition, final int childposition,                          boolean islastchild, view convertview, viewgroup parent) {      final string childtext = (string) getchild(groupposition, childposition);      if (convertview == null) {         layoutinflater infalinflater = (layoutinflater) this._context                 .getsystemservice(context.layout_inflater_service);         convertview = infalinflater.inflate(r.layout.list_item, null);     }      textview txtlistchild = (textview) convertview             .findviewbyid(r.id.lbllistitem);      txtlistchild.settext(childtext);     return convertview; }  @override public int getchildrencount(int groupposition) {     return this._listdatachild.get(this._listdataheader.get(groupposition))             .size(); }  @override public object getgroup(int groupposition) {     return this._listdataheader.get(groupposition); }  @override public int getgroupcount() {     return this._listdataheader.size(); }  @override public long getgroupid(int groupposition) {     return groupposition; }  @override public view getgroupview(int groupposition, boolean isexpanded,                          view convertview, viewgroup parent) {     string headertitle = (string) getgroup(groupposition);     if (convertview == null) {         layoutinflater infalinflater = (layoutinflater) this._context                 .getsystemservice(context.layout_inflater_service);         convertview = infalinflater.inflate(r.layout.list_group, null);     }      textview lbllistheader = (textview) convertview             .findviewbyid(r.id.lbllistheader);     lbllistheader.settypeface(null, typeface.bold);     lbllistheader.settext(headertitle);      return convertview; }  @override public boolean hasstableids() {     return false; }  @override public boolean ischildselectable(int groupposition, int childposition) {     return true;   } } 


Comments