In my android application in java, I am doing an http async request then I want to print the result in a TextView that is in a ScrollView.
This work fine when the result to print is short. But it can be very long and then the application is freezing for ~3-5 second.
I know this is because to much work is done on the main thread but is there a way to set the text of a TextView on a separeted thread ?
To illustrate this is my code in the onResponse of the httpRequest :
tView2.setText(requestName);
tView3.setText(message1);
tView4.setText(messag2);
tView4.setText(resultBody);
tView5.setText(message3);
If i just remove the line
tView4.setText(resultBody);
(where resultBody contains a long String) The UI does not freeze any more, and the other message are print almost instantly.
But when I let it the UI is freezing even before the print of the previous message so I can't even set a message of information preventing the user that can take some while (what I tried in my code, it's why there is 2 setText on the tView4)..
What I want is the simpliest solution to manage that. So an easy way to print a message of information to prevent the user would be good.
Thank you.