[英]Android Html.fromhtml() + SpannableString
I have html
string and SpannableString
in this string and I put it all in the TextView
, and the problem is in SpannableString
, it's not shown in Html.fromhtml()
.我在这个字符串中有html
字符串和SpannableString
,我把它们都放在TextView
,问题出在SpannableString
,它没有显示在Html.fromhtml()
。 How can I show SpannableString
in Html.fromHtml()
?如何在Html.fromHtml()
显示SpannableString
? Is it possible?是否有可能?
for(int index = 0; index < l.length; index++){ // have3d() return SpannableString
x += "<font color=\"green\">" + have3d(title[index]) + " </font> <br />" + l[index] + "<br/><br/>";
if(index == l.length-1){
x += "<font color=\"green\">" + title[index] + " </font> <br />" + l[index] + "<br/>";
}
}
mСinema.setText(Html.fromHtml(x));
Html.fromHtml
returns a Spanned
, that you can convert to a SpannableString
this way: Html.fromHtml
返回Spanned
,就可以转换为SpannableString
这种方式:
SpannableString text = new SpannableString(Html.fromHtml(x));
And then set it by calling:然后通过调用设置它:
mcinema.setText(text, BufferType.SPANNABLE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.