Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextView.setText() with very long string blocks UI thread

Is there a workaround for how long a TextView takes to set its text? I am trying to set a very long string and it ends up blocking the UI thread for a good 2-3 seconds because of that. Since I can't access the TextView from a different thread, I'm completely stumped.

Edit: Currently, I build up the string inside an AsyncTask doInBackground(), and only call TextView.setText() within the onPostExecute(which is running on the uiThread) The TextView is placed within a ScrollView

like image 229
jkau Avatar asked Oct 22 '22 07:10

jkau


1 Answers

You shouldn't have a problem loading even a couple of screens worth of information. If the string is super long, you might consider lazy loading the content in sections.

like image 167
Steven Mann Avatar answered Oct 24 '22 03:10

Steven Mann