哪一个使用的WebView或TextView的与它的HTML数据的列表? [英] Which one to use WebView or TextView in a list with HTML data in it?

查看:100
本文介绍了哪一个使用的WebView或TextView的与它的HTML数据的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在性能哪个好再次使用自定义阵列适配器定义的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.

这篇关于哪一个使用的WebView或TextView的与它的HTML数据的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆