lsjwzh / RecyclerViewPager

Deprecated
Apache License 2.0
3.53k stars 667 forks source link

ViewHolder.itemView' on a null object reference #146

Open Hitexroid opened 7 years ago

Hitexroid commented 7 years ago

RecyclerView.ViewHolder viewholder = mRecyclerViewPager.findViewHolderForAdapterPosition(Position);

java.lang.NullPointerException: Attempt to read from field 'android.view.View android.support.v7.widget.RecyclerView$ViewHolder.itemView' on a null object reference

ShubhamSrivastava93 commented 5 years ago

I am also facing same issue have you resolved it ?

vidjanidhi commented 5 years ago

have you resolved this issue? I m also facing this.

Hitexroid commented 5 years ago

Hi Sorry about my poor English !

Based on the features of RecyclerView. You can get only items that are visible And in RecyclerViewPager , because only one item is shown, no other items could be get !

Solution :

so you have to get your item in your List at specific position and edit...

yourModel item = itemList.Get(yourPosition);
item.test = "some text";

then :

itemList.set(yourPosition, item);
yourAdapter.notifyItemChanged(yourPosition);