简体   繁体   English

SpannableStringBuilder 只保留第一个 for 循环的格式

[英]SpannableStringBuilder only keeping formatting for the first for loop

I am trying to use a for loop to add formatting using SpannableStringBuild from strings in a list, however in the TextView , despite all the strings having been appended, only the string appended in the initial for loop keeps its formatting.我正在尝试使用 for 循环从列表中的字符串使用SpannableStringBuild添加格式,但是在TextView中,尽管已附加所有字符串,但只有初始 for 循环中附加的字符串保持其格式。

As we can't reuse instance of formatting style twice, all that had to be done was move the declaration of the formatting such as UnderlineSpan underlineSpan = new UnderlineSpan();由于我们不能重复使用格式化样式的实例两次,所以所要做的就是移动格式声明,例如UnderlineSpan underlineSpan = new UnderlineSpan(); inside the for loop.在for循环里面。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM