Sorry for my english , i have a question for you ( and thank you for your reply ). I have a recyclerview that componed with a checkbox and three textview. I want create this, when click first checkbox and click last checkbox i want that all range ( 0,1,2,3 ) are checked.
in my fragment i have this method:
recyclerView.postDelayed(new Runnable() {
@Override
public void run() {
for(int i=0; i<3; i++){
if(recyclerView.findViewHolderForAdapterPosition(i)!=null )
{ recyclerView.findViewHolderForAdapterPosition(i).itemView.findViewById(R.id.linearlayout_item).performClick();
}
}
}
},50);
and i not have a problem but when i change in this:
if ( posizione_elementi.size() == 2 ) {
for (int i = posizione_elementi.get(0); i <= posizione_elementi.get(1); i++) {
int finalI = i;
recyclerView.postDelayed(new Runnable() {
@Override
public void run() {
recyclerView.findViewHolderForAdapterPosition(finalI).itemView.findViewById(R.id.linearlayout_item).performClick();
}
},50);
}
}
I have this error "java.lang.NullPointerException: Attempt to read from field 'android.view.View androidx.recyclerview.widget.RecyclerView$ViewHolder.itemView' on a null object reference". Why i have this error ? and how can resolve ?.
Thank you for answered