Android custom adapter getView() NullPointerException out of nowhere! -
i've got custom adapter supply data listview. worked fine, 'suddenly'(i don't have word what's happening) app started crashing while loading activity listview:
w/dalvikvm( 228): threadid=3: thread exiting uncaught exception (group=0x4001b188) e/androidruntime( 228): uncaught handler: thread main exiting due uncaught exception e/androidruntime( 228): java.lang.nullpointerexception e/androidruntime( 228): @ advertisementlistadapter.getview(advertisementlistadapter.java:72) e/androidruntime( 228): @ android.widget.abslistview.obtainview(abslistview.java:1274) e/androidruntime( 228): @ android.widget.listview.measureheightofchildren(listview.java:1147) e/androidruntime( 228): @ android.widget.listview.onmeasure(listview.java:1060) e/androidruntime( 228): @ android.view.view.measure(view.java:7964) e/androidruntime( 228): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:3023) e/androidruntime( 228): @ android.widget.linearlayout.measurechildbeforelayout(linearlayout.java:888) e/androidruntime( 228): @ android.widget.linearlayout.measurevertical(linearlayout.java:350) e/androidruntime( 228): @ android.widget.linearlayout.onmeasure(linearlayout.java:278) e/androidruntime( 228): @ android.view.view.measure(view.java:7964) e/androidruntime( 228): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:3023) e/androidruntime( 228): @ android.widget.framelayout.onmeasure(framelayout.java:245) e/androidruntime( 228): @ android.view.view.measure(view.java:7964) e/androidruntime( 228): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:3023) e/androidruntime( 228): @ android.widget.framelayout.onmeasure(framelayout.java:245) e/androidruntime( 228): @ android.view.view.measure(view.java:7964) e/androidruntime( 228): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:3023) e/androidruntime( 228): @ android.widget.framelayout.onmeasure(framelayout.java:245) e/androidruntime( 228): @ android.view.view.measure(view.java:7964) e/androidruntime( 228): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:3023) e/androidruntime( 228): @ android.widget.framelayout.onmeasure(framelayout.java:245) e/androidruntime( 228): @ android.view.view.measure(view.java:7964) e/androidruntime( 228): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:3023) e/androidruntime( 228): @ android.widget.framelayout.onmeasure(framelayout.java:245) e/androidruntime( 228): @ android.view.view.measure(view.java:7964) e/androidruntime( 228): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:3023) e/androidruntime( 228): @ android.widget.linearlayout.measurechildbeforelayout(linearlayout.java:888) e/androidruntime( 228): @ android.widget.linearlayout.measurevertical(linearlayout.java:350) e/androidruntime( 228): @ android.widget.linearlayout.onmeasure(linearlayout.java:278) e/androidruntime( 228): @ android.view.view.measure(view.java:7964) e/androidruntime( 228): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:3023) e/androidruntime( 228): @ android.widget.framelayout.onmeasure(framelayout.java:245) e/androidruntime( 228): @ android.view.view.measure(view.java:7964) e/androidruntime( 228): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:3023) e/androidruntime( 228): @ android.widget.framelayout.onmeasure(framelayout.java:245) e/androidruntime( 228): @ android.view.view.measure(view.java:7964) e/androidruntime( 228): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:3023) e/androidruntime( 228): @ android.widget.framelayout.onmeasure(framelayout.java:245) e/androidruntime( 228): @ android.view.view.measure(view.java:7964) e/androidruntime( 228): @ android.view.viewroot.performtraversals(viewroot.java:763) e/androidruntime( 228): @ android.view.viewroot.handlemessage(viewroot.java:1633) e/androidruntime( 228): @ android.os.handler.dispatchmessage(handler.java:99) e/androidruntime( 228): @ android.os.looper.loop(looper.java:123) e/androidruntime( 228): @ android.app.activitythread.main(activitythread.java:4363) e/androidruntime( 228): @ java.lang.reflect.method.invokenative(native method) e/androidruntime( 228): @ java.lang.reflect.method.invoke(method.java:521) e/androidruntime( 228): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:860) e/androidruntime( 228): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618) e/androidruntime( 228): @ dalvik.system.nativestart.main(native method)
my getview method:
@override public view getview(int position, view convertview, viewgroup parent) { view view=convertview; viewholder holder; if(convertview==null){ view=inflater.inflate(r.layout.list_item, null); holder=new viewholder(); holder.imgitemimage=(imageview)view.findviewbyid(r.id.imgitemimage); holder.tvitemtitle=(textview)view.findviewbyid(r.id.tvitemtitle); holder.tvitemdetails=(textview)view.findviewbyid(r.id.tvitemdetails); view.settag(holder); }else holder=(viewholder)view.gettag(); holder.tvitemtitle.settext(data.get(position).getyear()+" "+data.get(position).gettitle()); stringbuilder sb=new stringbuilder(); sb.append(data.get(position).getprice()); sb.append("\n"); sb.append(data.get(position).getcity()); holder.tvitemdetails.settext(sb.tostring()); string imageurl="http://myuri/"+data.get(position).geturllist().get(0)+"/p-t.jpeg"; holder.imgitemimage.settag(imageurl); imageloader.displayimage(imageurl, activity, holder.imgitemimage); return view; }
when getview first called, convertview=null
, viewholder
object created. after calling findviewbyid(...)
members of viewholder class still null. so, here origins nullpointerexception
. view inflating successul can see during debug, view
object contains relativelayout
it's children. worst thing haven't changed part of app before started crashing! driving me nuts!
have tried rebuild application scratch? project -> clean
Comments
Post a Comment