android - RecyclerView with Glide causing NullPointer after scrolling up again -
here adapter class:
@override public recyclerview.viewholder oncreateviewholder(viewgroup parent, int viewtype) { view view = inflater.inflate(r.layout.container_accommodation,parent,false); myholder holder = new myholder(view); holder.setisrecyclable(false); return holder; } @override public void onbindviewholder(recyclerview.viewholder holder, final int position) { myholder myholder= (myholder) holder; accommodation current = data.get(position); picasso.with(context).load("http://10.0.2.2:18180/aafs/accommodations/"+current.accommoid+"/accomm_images/"+current.accommomainimage.imagename) .error(r.drawable.error) .into(myholder.imageview); }
here error when try scroll up again, scrolling down works fine.
fatal exception: main java.lang.nullpointerexception @ com.example.phuluso.aafs.adapteraccommodation.onbindviewholder(adapteraccommodation.java:73) @ android.support.v7.widget.recyclerview$adapter.onbindviewholder(recyclerview.java:5471) @ android.support.v7.widget.recyclerview$adapter.bindviewholder(recyclerview.java:5504) @ android.support.v7.widget.recyclerview$recycler.getviewforposition(recyclerview.java:4741) @ android.support.v7.widget.recyclerview$recycler.getviewforposition(recyclerview.java:4617) @ android.support.v7.widget.linearlayoutmanager$layoutstate.next(linearlayoutmanager.java:1994) @ android.support.v7.widget.linearlayoutmanager.layoutchunk(linearlayoutmanager.java:1390) @ android.support.v7.widget.linearlayoutmanager.fill(linearlayoutmanager.java:1353) @ android.support.v7.widget.linearlayoutmanager.scrollby(linearlayoutmanager.java:1180) @ android.support.v7.widget.linearlayoutmanager.scrollverticallyby(linearlayoutmanager.java:1031) @ android.support.v7.widget.recyclerview$viewflinger.run(recyclerview.java:4061) @ android.view.choreographer$callbackrecord.run(choreographer.java:725) @ android.view.choreographer.docallbacks(choreographer.java:555) @ android.view.choreographer.doframe(choreographer.java:524) @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:711) @ android.os.handler.handlecallback(handler.java:615) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:4944) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1038) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:805) @ dalvik.system.nativestart.main(native method)
any great.
thanks.
did override getitemcount method in adapter?
@override public int getitemcount(){ return data.size(); }
it seems onbindviewholder(vh holder, int position)
method supplying invalid position parameter. when accommodation data collection returns null. type of collection using hold accommodations?
Comments
Post a Comment