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()
. How can I show SpannableString
in Html.fromHtml()
? 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:
SpannableString text = new SpannableString(Html.fromHtml(x));
And then set it by calling:
mcinema.setText(text, BufferType.SPANNABLE);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.