android - Unable to download .jpg image and set into imageview using asynctask -
have problem. can't seem download .jpg image url source , set imageview inside listview. gives me error "nullpointerexception". using imagedownloader class here.
this lines of code download image files:
oncreate()...
(int = 0; < listdata.size(); i++) { imageisbn = listdata.get(i).get("coverimage"); string isbnurl = "http://lib.syndetics.com/index.aspx?isbn=" + imageisbn + "/sc.gif&client=tpoly&type=xw12"; imageview iv = (imageview) findviewbyid(r.id.cover_image); imagedownloader.download(isbnurl,iv); }
i'm thinking maybe due setcontentview(r.layout.list) that's producing error since listview , imageview link in xml file.
below logcat:
05-11 09:26:58.063: error/androidruntime(305): java.lang.runtimeexception: unable start activity componentinfo{com.tplibrary/com.tplibrary.search.searchresults}: java.lang.nullpointerexception 05-11 09:26:58.063: error/androidruntime(305): @ android.app.activitythread.performlaunchactivity(activitythread.java:2663) 05-11 09:26:58.063: error/androidruntime(305): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2679) 05-11 09:26:58.063: error/androidruntime(305): @ android.app.activitythread.access$2300(activitythread.java:125) 05-11 09:26:58.063: error/androidruntime(305): @ android.app.activitythread$h.handlemessage(activitythread.java:2033) 05-11 09:26:58.063: error/androidruntime(305): @ android.os.handler.dispatchmessage(handler.java:99) 05-11 09:26:58.063: error/androidruntime(305): @ android.os.looper.loop(looper.java:123) 05-11 09:26:58.063: error/androidruntime(305): @ android.app.activitythread.main(activitythread.java:4627) 05-11 09:26:58.063: error/androidruntime(305): @ java.lang.reflect.method.invokenative(native method) 05-11 09:26:58.063: error/androidruntime(305): @ java.lang.reflect.method.invoke(method.java:521) 05-11 09:26:58.063: error/androidruntime(305): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:868) 05-11 09:26:58.063: error/androidruntime(305): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:626) 05-11 09:26:58.063: error/androidruntime(305): @ dalvik.system.nativestart.main(native method) 05-11 09:26:58.063: error/androidruntime(305): caused by: java.lang.nullpointerexception 05-11 09:26:58.063: error/androidruntime(305): @ com.tplibrary.search.imagedownloader.forcedownload(imagedownloader.java:80) 05-11 09:26:58.063: error/androidruntime(305): @ com.tplibrary.search.imagedownloader.download(imagedownloader.java:49) 05-11 09:26:58.063: error/androidruntime(305): @ com.tplibrary.search.searchresults.oncreate(searchresults.java:185) 05-11 09:26:58.063: error/androidruntime(305): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) 05-11 09:26:58.063: error/androidruntime(305): @ android.app.activitythread.performlaunchactivity(activitythread.java:2627) 05-11 09:26:58.063: error/androidruntime(305): ... 11 more
so guys, ideas? i'm using imagedownloader class wrongly?
in imagedownloader class, mode assigned no_async_task:
public enum mode { no_async_task, no_downloaded_drawable, correct } private mode mode = mode.no_async_task;
your intention download image. try setting mode variable no_downloaded_drawable.
Comments
Post a Comment