How can we create horizontal recycler view in android.
private fun handleScroll(
layoutManager: LinearLayoutManager,
homeItemViewHolder: HomeItemViewHolder?, position: Int
) {
homeItemViewHolder?.rcvHomeItems?.addOnScrollListener(object :
RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
rcvrecyclerView = recyclerView
val lastItem: Int = layoutManager.findLastCompletelyVisibleItemPosition()
val firstItem: Int = layoutManager.findFirstVisibleItemPosition()
Log.i("firstItem", firstItem.toString())
if (lastItem != -1) {
if (lastItem == layoutManager.itemCount - 1) {
Log.d("lastItem", lastItem.toString())
Log.d("lastItem2", (layoutManager.itemCount - 1).toString())
Log.d("position", position.toString())
mHandler.removeCallbacks(SCROLLING_RUNNABLE)
val postHandler = Handler()
postHandler.postDelayed({
recyclerView.adapter = null
notifyItemChanged(position)
//recyclerView.adapter = catHomeAdapter
mHandler.postDelayed(SCROLLING_RUNNABLE, 14000)
}, 14000)
}
}
}
})
mHandler.postDelayed(SCROLLING_RUNNABLE, 14000)
}
I have Try this but there comes the different problem in auto slider. Sometime the slider get faster unusual. Can AnyOne Provide best way to make recycler view auto slide. Thanks in advance