I have two values in list and displaying that in horizontal list view using Recycler view. Here I need to auto scroll the horizontal list unlimited. I tried with the below c
trainigItemRV.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int lastItem = linearLayoutManager.findLastCompletelyVisibleItemPosition();
if(lastItem == linearLayoutManager.getItemCount()-1){
mHandler.removeCallbacks(SCROLLING_RUNNABLE);
Handler postHandler = new Handler();
postHandler.postDelayed(new Runnable() {
@Override
public void run() {
trainigItemRV.setAdapter(null);
trainigItemRV.setAdapter(productsTrainingItemAdapter);
mHandler.postDelayed(SCROLLING_RUNNABLE, 2000);
}
}, 2000);
}
}
});
mHandler.postDelayed(SCROLLING_RUNNABLE, 2000);
This Works For me..