In BindViewHolder method I have used -
new CountDownTimer(10000, 1000) {
public void onTick(long millisUntilFinished) {
holder.timer_tv.setText(String.format("00:%02d", millisUntilFinished / 1000));
}
public void onFinish() {
holder.switchScreen();
}
}.start();
and in holder I have used switchScreen method
private void switchScreen() {
System.out.println("SWITCH ADAPTER POSITION: " + getAdapterPosition());
if (getAdapterPosition() < list.size() - 1) {
recyclerView.scrollToPosition(getAdapterPosition() + 1);
System.out.println("SWITCH1: " + getAdapterPosition());
} else {
System.out.println("SWITCH2: " + getAdapterPosition());
context.startActivity(new Intent(context, WordTestResultActivity.class).putExtra("correct_words", correct_words).putExtra("total_words", total_words));
((WordTestActivity) context).finish();
}
}
Example : If I have 4 items in RecyclerView then switchScreen() skipping some items but I want each one to show one by one.
If I use a button in holder, implement its click listener and on click event I use this switch screen method it works good by showing each item one by one.