On Sun, Apr 17, 2011 at 8:05 PM, NT <[email protected]> wrote:

> What should one do if there are multiple timers?
>

You can abstract the concept presented in the article to create your own
Timer class, of which you can create multiple instances for each of your
list items requiring a timer.


> If the main UI thread is used to continuously update multiple timers, will
> that not make the application less responsive?
>

All the UI thread does is schedule the timer to come back at some time. When
it comes back at that time it updates the UI and reschedules the timer. If
this makes the app less responsive you have a problem.

Is there a recommended way to (1) associate a timer with each item in a
> ListActivity


class Timer { /* your timer implementation */ }
class MyObjectInTheList { private Timer mTimer; }


>  and (2) update multiple timers?
>

Conceptually, a timer is not something you "update". A timer is something
that *ticks* away and eventually *expires*. You don't care about the
updating, you care about when the timer expires. So your Timer
implementation could have a callback that fires when it expires (when the
handler you scheduled in the timer gets called). So you could register a
listener in your activity for each item. The listener gets called when that
item's timer expires and the listview or activity knows that it needs to
update the corresponding item's visual representation (the TextView).

Or something like that.

-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to