java - App crashes when filtering SimpleAdapter while images are still loading -


/** asynctask parse json data , load listview */         private class listviewloadertask extends asynctask<string, void, string>{             // doing parsing of xml data in non-ui thread             @override             protected string doinbackground(string... strjson) {                 try{                     jobject = new jsonobject(strjson[0]);                     storejsonparser countryjsonparser = new storejsonparser();                     countryjsonparser.parse(jobject);                 }catch(exception e){                     log.d("json exception1",e.tostring());                 }                  // instantiating json parser class                 //storejsonparser countryjsonparser = new storejsonparser();                  try{                     // getting parsed data list construct                     countries = countryjsonparser.parse(jobject);                 }catch(exception e){                     log.d("exception",e.tostring());                 }                 return null;             }          /** invoked android on "doinbackground" executed */         @override         protected void onpostexecute(string result) {              // setting adapter listview             adapter = new simpleadapter(choosecategory.this, countries, r.layout.restaurant_list, from, to);             mlistview.setadapter(adapter);             log.d("what countries?", string.valueof(countries));             searchbox.addtextchangedlistener(new textwatcher() {                  public void ontextchanged(charsequence cs, int arg1, int arg2, int arg3) {                     //adapter.getfilter().filter(cs);                     adapter.getfilter().filter(cs.tostring().trim());                 }                  public void beforetextchanged(charsequence arg0, int arg1, int arg2,                                               int arg3) {                     // todo auto-generated method stub                  }                  public void aftertextchanged(editable arg0) {                     // todo auto-generated method stub                     //choosecategory.this.adapter.getfilter().filter(arg0);                     //adapter.getfilter().filter();                 }             });              for(int i=0;i<adapter.getcount();i++){                 hashmap<string, object> hm = (hashmap<string, object>) adapter.getitem(i);                 string imgurl = (string) hm.get("flag_path");                 imageloadertask imageloadertask = new imageloadertask();                  hashmap<string, object> hmdownload = new hashmap<string, object>();                 hm.put("flag_path",imgurl);                 hm.put("position", i);                  // starting imageloadertask download , populate image in listview                 imageloadertask.execute(hm);             }         }     }  

error logcat

java.lang.classcastexception: java.lang.integer cannot cast java.lang.string             @ android.widget.simpleadapter$simplefilter.performfiltering(simpleadapter.java:352)             @ android.widget.filter$requesthandler.handlemessage(filter.java:234)             @ android.os.handler.dispatchmessage(handler.java:102)             @ android.os.looper.loop(looper.java:136)             @ android.os.handlerthread.run(handlerthread.java:61)  java.lang.nullpointerexception             @ android.widget.simpleadapter.getcount(simpleadapter.java:93)             @ android.widget.adapterview.checkfocus(adapterview.java:713)             @ android.widget.adapterview$adapterdatasetobserver.oninvalidated(adapterview.java:836)             @ android.widget.abslistview$adapterdatasetobserver.oninvalidated(abslistview.java:6288)             @ android.database.datasetobservable.notifyinvalidated(datasetobservable.java:50)             @ android.widget.baseadapter.notifydatasetinvalidated(baseadapter.java:59)             @ android.widget.simpleadapter$simplefilter.publishresults(simpleadapter.java:383)             @ android.widget.filter$resultshandler.handlemessage(filter.java:282)             @ android.os.handler.dispatchmessage(handler.java:102)             @ android.os.looper.loop(looper.java:136)             @ android.app.activitythread.main(activitythread.java:5017)             @ java.lang.reflect.method.invokenative(native method)             @ java.lang.reflect.method.invoke(method.java:515)             @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779)             @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595)             @ dalvik.system.nativestart.main(native method) 

i able search via searchbox when images loaded. crashes when type in searchbox while images still loading. have tried google couldn't find solution close this. know what's wrong ? in advance help!

in simple adapter null pointering on mdata. countries must null when construct adapter.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -