开发者

Processing large Spanned objects with TextView (setText)

Well, to give you a bit of history on this project - I'm parsing a string that's about 100k in a child thread, and returning the Spanned object from Html.fromHtml().

The issue is when it returns to the main thread - when trying to setText using the Spanned that was just created in another thread, it takes quite a long time processing it from a Spanned object into a displayable format (setText).

I would normally process this in the child thread, but unfortunately, since this is related to the UI, I can't - has to be on the main thread. So, my question is whether there is a way to process the Spanned into something easily interpr开发者_开发问答eted by the setText, so that it doesn't spend a lot of time on the main thread processing it after the child thread has finished.

testQuestionsExplanations.setText(spannedExplanationsObj);

My biggest issue is that it locks the main thread down doing this.


I found a work around for my problem.

Instead of sending the whole Spanned object and getting it processed onto the TextView all at once, I'm sending smaller pieces, and just appending them to the TextView.

This way my ProgressDialog doesn't lock up completely - it's jerky, but it's better than not moving at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜