android - java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification - List with Universal Image Loader -


i trying update fragment list view once async call complete getting following error :

java.lang.illegalstateexception: content of adapter has changed listview did not receive notification.

i updating adapter onpostexecute , have checked function running on main thread still getting illegalstateexception.

@override     protected void onpostexecute(list<string> result) {         if (null != mclient)             mclient.close();         //todo             //constants.images = result.toarray(new string[result.size()]);         constants.images.addall(result);             log.i("images", images.tostring());             if (mthelistener != null && firstcallflag ) {                 firstcallflag = false;                 mthelistener.gotonextscreen();             }else{                 dataupdatelistener.dataupdated(result);             }     }  @override     protected list<string> doinbackground(void... params) {          if(aftertag != null){             url += "?after="+aftertag;             system.out.println("::new url:: "+ url);         }         httpget request = new httpget(url);         jsonresponsehandler responsehandler = new jsonresponsehandler();         try {             return mclient.execute(request, responsehandler);         } catch (clientprotocolexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         }         return null;     }   @override public void dataupdated(list<string> data) {     // todo auto-generated method stub     system.out.println("::notify data update listener called");     system.out.println("looper "+looper.mylooper());     system.out.println("main looper "+looper.getmainlooper());     imageurls.addall(data);     madapter.notifydatasetchanged(); } 

//fragment oncreateview - adapter set here

@override public view oncreateview(layoutinflater inflater, viewgroup container,         bundle savedinstancestate) {     view rootview = inflater.inflate(r.layout.fr_image_list, container,             false);     listview = (listview) rootview.findviewbyid(android.r.id.list);      // adding load more      // loadmore button     button btnloadmore = new button(getactivity().getapplicationcontext());     btnloadmore.settext("load more");      // adding load more button lisview @ bottom     listview.addfooterview(btnloadmore);      /**      * listening load more button click event      * */     btnloadmore.setonclicklistener(new view.onclicklistener() {          @override         public void onclick(view arg0) {             // starting new async task             constants.geturlfromredditservice();         }     });     madapter = new imageadapter();     ((listview) listview).setadapter(new imageadapter());      listview.setonitemclicklistener(new onitemclicklistener() {         @override         public void onitemclick(adapterview<?> parent, view view,                 int position, long id) {             startimagepageractivity(position);         }     });     return rootview; } 

p.s: using universal image loader populate images on list .

try replacing below line of code

 ((listview) listview).setadapter(new imageadapter()); 

with

 ((listview) listview).setadapter(madapter); 

see listview setting new adapter , in onpostexecute notifying different instance of adapter


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -