如何从Java的文本视图中获取HTML代码?

发布于 2025-01-17 14:40:21 字数 361 浏览 1 评论 0原文

我看到这个主题告诉我如何在Java中的TextView中显示HTML文本。例如,如果我的 TextView 有“Hello”作为其文本,并且我使用了该主题中的代码,我会在 TextView 中看到一个小“Hello”。

现在我想扭转这一局面。我想获取我已启用HTML格式的TextView的HTML代码,即我想获取“Hello!”。有办法做到这一点吗?

我尝试过 tv.getText() (tv 是 TextView 的名称),但它返回了“Hello”,而不是我预期的那样。

I saw this topic that tells me how to display HTML text in a TextView in Java. For example, if my TextView has "<small>Hello</small>" as its text and I used the code in that topic, I would see a small "Hello" in my TextView.

Now I want to reverse this. I want to get the HTML code of the TextView that I have enabled HTML format, i.e., I want to get "<small>Hello!</small>". Is there a way to do this?

I have tried tv.getText() (tv is the name of the TextView), but it instead returned "Hello", not as I had expected.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文