Which one to use WebView or TextView in a list with HTML data in it?

前端 未结 2 1098
迷失自我
迷失自我 2021-02-13 21:13

In the name of performance which is better to use list of webview objects with custom array adapter defined or list of textview object again with custom adapter and html content

2条回答
  •  爱一瞬间的悲伤
    2021-02-13 21:39

    WebView does not work well as a child of ListView, since both WebView and ListView know how to scroll. Hence, I would use TextView. Limit your HTML to the tags that Html.fromHtml() supports. Here is a list of supported tags from Android 2.1, and other versions of Android are probably similar.

    With respect to performance, TextView is indeed a significantly lighter widget and would perform better in any case. You may want to cache your Html.fromHtml() output, though, so you do not have to re-do that for a given row as the user scrolls.

提交回复
热议问题