views:

14

answers:

1

Right now I am using the following cod eot update a textview:

txtMain.setText("new text");

After that code executes, the screen does not update with the new text. Is there a way I can force the text to update right then and there?

+1  A: 

After that code executes, the screen does not update with the new text

It should, once you return control to Android.

Suppose, for example, you tried doing a Thread.sleep(5000); immediately after the setText() call. The text will not appear on the screen, because Android's main application thread is tied up sleeping and cannot redraw the screen.

So, make sure that you return from whatever callback you are in (onCreate(), onClick(), onListItemClick(), etc.), and Android should update the screen momentarily.

CommonsWare
in addition to CommonsWare's suggestions, make sure that you are passing your TextView into `setContentView(View v)` so that the system is actually adding it to the screen. If you dont do that, nothing will ever display.
mtmurdock