Right now I am using the following code to 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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It should, once you return control to Android.
Suppose, for example, you tried doing a
Thread.sleep(5000);immediately after thesetText()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.