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. Rom mana yang oke skarang?

Guys,
Beberapa hari yg lalu saya pakai rom jackxheroski 1.4+kernel.
Rom yg bagus menurut saya. Terutama terasa si browsernya yg hampir bisa buka 
semua web.
Konon salah satu web yg sulit dibuka oleh device adalah: www.a338.com web judi 
online:-)  (please saya bukan org yg ngerti judeng, cuma kemarin ditantangin 
buka web itu pake android yg saya bilang canggih, konon web tsb ngga bisa 
dibuka pake iphone)
Yg nantangin kaget ketika web bisa dibuka bahkan bisa masuk ke dalam untuk 
siap2 main kartu.

Karena jiwa mau nyoba yg terbaik, saya hari ini flash pakai rom haykuro yg. 
terakhir. Sangat senang karena ada app footprint, dimana kita bisa foto sebuah 
lokasi yg bisa dilihat posisinya di google map.
Tapi rom ini rasanya lebih lambat, tapi sangat bagus di sisi scroll app, lebih 
smooth. Nah di rom ini web nya tidak sebaik si jack, tp kecepatan trima posisi 
gps nya better.

Skarang saya lihat si jack sudah sampai versi 1.6, cepat sekali org ini bikin 
rom.
Kabarnya rom ini cepat tapi gps not working?

Ada yg sudah coba?

Yg saya males klo ganti rom adalah instal software lagi, walau bisa dibackup 
pakai astro, tp one by one lagi kliknya. Trus nyusun setiap kelompok app di 
tiap halaman depan. Apa ada aplikasi backup yg bisa restore supaya kita ngga 
harus intall lg software dan harus susun app lagi? Soalnga nyoba di app my 
backup ngga berhasil klo kota naik ke rom hero.
Tp di rom si haykuro, app yg ada di sd card dia keluarkan otomatis, ngga perlu 
install lagi, hanya tinggal kelompokkan di 7 halaman atas.
Trus gimana caranya bisa pertahankan app footprint di rom lain yg tidak 
tersedia ya?

Tolong share pengalaman pakai rom2 lain ya. Thanks.

Salam,

Lucky Sebastian

-@ my google android phone-




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

2. problem using progress dialog with usertask

Hi,

I have an application that downloads some content from the network,
processes it and displays it.
When any link is clicked, the user task(async task) is used to
download and process the content and the content is shown in the new
activity.

I want to show a progress dialog until the content gets downloaded and
processed. But when i call the progessdialog.show() method I am
getting the following error.

'android.view.WindowManager$BadTokenException: Unable to add window --
token android.os.binderpr...@435904d8 is not valid; is your activity
running'

I use the get method to get the result from the user task. I make the
main thread to wait until the usertask
completes its work. I know this is a bad way, but the normal handler
does not work here.I think it is not good idea to start a new activity
in the onPostExecute method.

Please tell me how to do this.

Thanks in advance.

V. Sundar
--~--~---------~--~----~------------~-------~--~----~

3. Market (By Date category)

4. Very simple question about the HTC phones with trackballs (like the G1)

5. How does ResolverActivity or ChooserActivity getting launched?

6. How does ResolverActivity or ChooserActivity getting launched?

7. about adc2 app