I am struggling with a problem. I have an activity that has a RecyclerView with images. The RecyclerView is filled throught adapter, and that's works fine, and I got his starting screen.
After this I want to change this images in a loop with a pause of 2 seconds randomly. That is where I need help, because what I already tried, showed the end screen immediately, there is time between 2 image changes, and this is what shows.
I am trying this to achieve in the onStart function calling hideElements() function. Here is my hideElements() function:
private fun hideElements()
{
if(recyclerView.adapter?.itemCount == 0)
{
return
}
var hideOrdder: ArrayList<Int> = ArrayList<Int>()
for (i in 0 until recyclerView.adapter?.itemCount!!)
{
hideOrdder.add(i)
}
hideOrdder.shuffle()
for(i in hideOrdder)
{
_gridElementList[i].drawableId = R.drawable.kerojel
handler = Handler()
runnable = Runnable {
adapter!!.notifyItemChanged(i)
}
runOnUiThread {
handler!!.postDelayed(runnable!!, 10000)
}
}
}
I tried also to create a thread, but I failed. thnx