WebView 类中 loadData() 和 loadDataWithBaseURL() 之间的区别......?

发布于 2024-10-10 21:16:32 字数 313 浏览 0 评论 0原文

谁能告诉我 WebView 类中 loadData() 和 loadDataWithBaseURL() 之间的区别。

当我在程序中使用 web.loadDataWithBaseURL("",html, mimetype,encoding,""); 时,其中 html 是包含硬编码 html 标签的字符串,其显示就像 html 页面一样 当我在代码中使用 loadData(html,mimetype,encoding) 时,应用程序正在关闭。

我读了 API 但无法理解...... 所以请帮助我...

提前致谢

Ash

can anybody tell me the difference between loadData() and loadDataWithBaseURL() in WebView class.

when i used web.loadDataWithBaseURL("",html, mimetype, encoding,""); in my program , where html is the string that contains hard coded html tags, its displaying just like as html page
where as when i used loadData(html,mimetype,encoding) in my code the application is closing.

i read the API but could not understand it.....
so please help me...

Thanks in Advance

Ash

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌辣 2024-10-17 21:16:32

如果有人遇到此问题,WebView.loadData 似乎已损坏:

http://code .google.com/p/android/issues/detail?id=1733#c23

http://code.google.com/p/android/issues/detail?id=3552

OP问题中建议的解决方案的变体似乎是解决方法。我认为空值比“”便宜,所以我用了这个:

web.loadDataWithBaseURL(null,html, "text/html", "utf-8",null);

In case someone comes across this, WebView.loadData seems to be broken:

http://code.google.com/p/android/issues/detail?id=1733#c23

http://code.google.com/p/android/issues/detail?id=3552

Variants of the solution suggested in the OP's question seems to be the workaround. I figure nulls are cheaper than "", so I used this:

web.loadDataWithBaseURL(null,html, "text/html", "utf-8",null);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文