In order to update a UI control (TextView) periodically, I create a Runnable 
which updates the control but instead of creating an explicit Handler and 
posting the runnable to that, I post the runnable directly to the control. I 
find the later to be simple but most readings on the web seem to be using an 
explicit Handler object. Any reasons, I should be careful about?  

Runnable runnable = new Runnable() { 
@Override
public void run() {
textview.setText(String.valueOf(counter));
textview.postDelayed(runnable, 20000);
}
};

@Override 
public void onResume() {
super.onResume();
textview.post(runnable); 
}


@Override 
public void onPause() {
        super.onPause(); 
        textview.removeCallbacks(runnable);
    }

---
Take care,
Pankaj

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to