从获得的Html风格的TextView文本 [英] Get text from Html styled TextView
本文介绍了从获得的Html风格的TextView文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个TextView其中包含文本和HTML属性,如订阅, 例如,它是一种化学式为H 2 SO 4 。我怎样才能从TextView的这段文字,而是用订阅(字符串不是显示下标)
I have a TextView which contains text with Html attributes like subscription, for example it's a chemical formula H2SO4. How can I get this text from textview, but with subscriptions (String isn't showing the subscript)
在这里你可以看到屏幕截图 https://www.dropbox.com/s/0u9vtmqaxdnqfy5/Capture.PNG
here you can see screenshot https://www.dropbox.com/s/0u9vtmqaxdnqfy5/Capture.PNG
推荐答案
要设置的 ^ h 2 SO 4 在TextView中,使用下标
标记
To set H2SO4 in textview,Use subscript
tag as
textview.setText(Html.fromHtml("H<sub>2</sub>SO<sub>4</sub>"), TextView.BufferType.EDITABLE);
其中,的TextView
是你的TextView的标签。
where textview
is your Textview's tag.
和得到的TextView文本
And get text from textview as
String str = Html.toHtml(textview.getEditableText()).toString();
anothertextview.setText(Html.fromHtml(str));
有关详细信息请参见选择,突出,或文字定型部分>
这篇关于从获得的Html风格的TextView文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文