Re: [android-developers] Re: update TextView inside a TimerTask
Hi
thanks
i wonder if you help me with an example!
i implemented timer like this:
my texview is this:
-- thanks
i wonder if you help me with an example!
i implemented timer like this:
Timer t = new Timer();
TimerTask tt = new TimerTask() {
@Override
public void run() {
}
};
t.scheduleAtFixedRate(tt, 100, 1000);
my texview is this:
TextView tv = (TextView)findViewById(R.id.TextView06);
tv.setText( String.valueOf(myval));
On Tue, Mar 13, 2012 at 9:03 AM, tsukishiro yamazaki <tsukishiro88@gmail.com> wrote:
If I'm not mistaken, any code inside a TimerTask is running on a different thread. This means that it won't have access to the main UI thread. So if you put some code in there to update your Textview, you will probably end up with an exception or error saying that it cannot access the main ui thread. To fix this, you will need to create a message handler (Handler) so that you can send "messages" to your main ui thread telling it to update the Textview accordingly.
On Tuesday, March 13, 2012 1:20:18 PM UTC+9, Ali wrote:Hi--
i have made a timer and a timer task, and i need to update my textview every seconds
how can i do that?
thanks
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
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 post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home