So I need one of two options but don't know where to start with either.
I have a list card views in a recyclerview. Each card view needs to have countdown timer implemented and able to run simultaneously. (Seems like the harder option) OR
Update the text in a card view based on if a specified time has elapsed or system time reaches a specified minute and hour.
To make the cards with different timers you will need threads. And the easiest way in Android is
AsyncTask
. So you create a bunch ofAsyncTask
s (probably you'd want anArrayList
to which you will add theAsyncTask
s) and then with a cycle simply.execute()
them.Making an
AsyncTask
is very easy. You simply make a new class that is derived fromAsyncTask
and implement thedoInBackground()
method.P.S. If you're developing for Android 3.0 and higher you will need to launch AsyncTasks this way:
This will make them run simultaneously
UPDATE
As stated by others in other posts you have to know when to start and stop the timer because this is making you problems. I manged to make this work without canceling the recycler so here is my code. Hope it helps. Any feedback is appreciated.