哪一个使用的WebView或TextView的与它的HTML数据的列表?它的、数据、列表、WebView

2023-09-05 06:08:05 作者:|▍醉傾城°

在性能哪个好再次使用自定义阵列适配器定义的WebView对象或TextView的对象的名单列表,自定义适配器和HTML内容it.First显示我尝试使用web视图,但我认为web视图对象的名称是一种沉重的UI元素,TextView中显得更加轻巧。

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 to show in it.First I try to use webview but i think webview object is kind of heavy ui element , textview seems more lightweight.

WebView entryWebView = (WebView) findViewById(R.id.entryWebView);
                entryWebView.loadData("my hmtl formatted data", "text/html", "utf-8");

//假设在自定义阵列适配器这些定义和充满的WebView对象

//suppose these defined in custom array adapter and filled with webview objects

TextView entryTextView = (TextView) v.findViewById(R.id.entry);
                entryTextView.setText("my html formatted data");

//又一次这一个自定义阵列适配器,充满了TextView的对象

//and this one again in custom array adapter and filled with textview objects

推荐答案

的WebView 的ListView的孩子没有正常工作,因为这两个的WebView 的ListView 知道如何滚动。因此,我会使用的TextView 。限制你的HTML到Html.fromHtml 标记()支持。这里是一个支持标签的列表,Android 2.1的和可能是相似的其他版本的Andr​​oid。

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.

对于性能,的TextView 的确是一个显著较轻的小部件,并在任何情况下有更好的表现。您可能需要缓存你的 Html.fromHtml()输出,但是,这样你就不必重新做,对于一个给定的行作为用户滚动。

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.