SpannableStringBuilder only keeping formatting for the first for loop

52 Views Asked by At

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.

1

There are 1 best solutions below

0
Tamzid On BEST ANSWER

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(); inside the for loop.