TextView.setText doesn't update

by Midian » Tue, 14 Apr 2009 13:04:40 GMT


Sponsored Links
 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();

--~--~---------~--~----~------------~-------~--~----~



TextView.setText doesn't update

by Peter Carpenter » Wed, 15 Apr 2009 02:05:53 GMT


 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();




--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Flash and future of Android game development?

Well considering how cpu hungry flash is, I'm pretty sure there are a LOT of
things that can't be implemented.  Basically, it's like choosing between
using the android framework or html/webkit to make an app.

It's just another tool to get something accomplished.  In the end just use
the tool that works best.




Hi All,

With the promising news of Flash support for Android what will the future of
Android Game development?


--
Best Regards,
Atif Gulzar

I  Unicode, zln 


--

2. Developer console stopped updating?

My "total" and "active install" numbers in Developer Console have not
been changing for more than 36 hours -- for all 5 apps that I publish.
Has anyone seen the same thing?

The ranking of my apps haven't been dropping yet (touch wood) so maybe
just I am getting a stale view of the numbers?

Gods of google, if you have time, please check statistics of
com.nubinews.fullreader

Thanks!

3. How to retrive all elements from Res/Raw folder in one shot at run time

4. Probably a simple Canvas Drawing question. Please answer

5. Does Android Eclair code base support "Plugins" in "Android Browser"?

6. how to use maindictionary

7. How to compile/build only one Driver file?