简体   繁体   English

字符串返回标签而不是格式化文本

[英]String returns tags and not formatted text

Code: 码:

StringBuilder sb = new StringBuilder();
sb.append(String.format("<b>%s. %s</b> %s", Integer.toString(id), name, description));
derp.setText(sb.toString());

Returns: 返回值:

< b>id. <b> id。 name< /b> description 名称</ b>描述

Wanted outcome: 想要的结果:

id. ID。 name description 名称说明

尝试以下方法:

derp.setText(Html.fromHtml(sb.toString()));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java getTime()从格式化的字符串返回null - Java getTime() returns null from formatted String HttpClient 的 HttpResponse 返回非格式化字符串 - HttpClient's HttpResponse returns non formatted String JAVAFX文本区域未显示字符串的格式化输出 - JAVAFX Text Area is not showing formatted output of the string EditText 无法将文本设置为格式化字符串 - EditText can't set text the formatted string 使用调用另一个类的getter,并将该类作为格式化字符串返回? - Using a getter that calls another class, and returns that class as a formatted string? 创建一个toString()方法,该方法以格式化的时间字符串形式返回值 - Create a toString() method that returns the value as a formatted time String 在带有XML标签的字符串上使用正则表达式提取标签之间的标签和文本 - Extracting tags and text between tags using regex on an string with XML tags 捕获文本,包括字符串中的标签,然后使用文本对标签重新排序 - capture text, including tags from string, and then reorder tags with text 在Java中的超大格式文本文件中查找字符串 - Find a string in a very large formatted text file in java 在剪贴板中插入字符串而不会丢失格式化的文本/样式 - Insert string in clipboard without lost formatted text / style
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM