In the Android framework, if a TextView\'s setText() method is called, and after it returns Thead.sleep() is called, then the screen of the device does not display the given
1)Never sleep that long on the UI thread. In fact, never sleep on it at all. That causes it to block and makes the phone unresponsive
2)setText calls invalidate on the view. That will cause the framework to draw the view again as soon as its able- but that means needs to finish the current things its doing and get back to the main Looper (basically, it needs to return from whatever method in your code it first calls). Until then, the change won't be visible on screen.
Edit: to put it another way, inside the framework we have
do{
Message msg = nextMessage();
if(msg.what == ON_CREATE){
currentActivity.onCreate();
}
else if(msg.what == DRAW){
rootView.onDraw();
//draw entire screen
}
else
... //Thousands of more events like touches, handlers, etc
It can't get to the draw message until its done with the current message. Its single threaded.