Hi,

I'm not sure which thread timers fire in, but have you tried calling the
setText explicitly from the UI thread?

final String timeSinceUpdate = tracker.getUpdateAge();
runOnUiThread(new Runnable()
{
    public void run()
    {
        mMyTextView .setText("Current location (" + timeSinceUpdate +
")";
    }
}

Peter.

-----Original Message-----
From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of Midian
Sent: Tuesday, 14 April 2009 9:44 AM
To: Android Developers
Subject: [android-developers] TextView.setText doesn't update


I have a Timer set up to update a TextView field once every second.
Thing is, I can't see any changes on screen!

Debugging shows...
setText inside the timer function *is* being called.
getText called on the text view returns the *correct* (new) text that
just isn't displayed!

I've tried TextView.postInvalidate() to no effect.
Code below.

Anyone seen this before?
Thanks.

------------------------------------------------------------------------
----------------
IN MyActivity.onCreate:
        mMyTextView = (TextView)this.findViewById
(R.id.txtcurloctitle);

FROM MyTimerTask.Run
        String timeSinceUpdate = tracker.getUpdateAge();
        mMyTextView .setText("Current location (" + timeSinceUpdate +
"):");

IN MyActivity.onOptionsItemSelected:
        AlertDialog.Builder msg = new AlertDialog.Builder(this);
        msg.setTitle("Debug");
        msg.setMessage(mMyTextView.getText());
        msg.setPositiveButton("OK", null);
        msg.show();




--~--~---------~--~----~------------~-------~--~----~
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-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to