Solution 1 :
A single span can only have one location within a SpannableString or SpannableStringBuilder. To color multiple ranges, you need to create a different span for each range.
Problem :
I’m creating a calculator app using Kotlin. I want to highlight the operation characters (+, -, *, /) by making their color blue.
The array operationsInStrings is filled with indexes of characters from string that I wish to change the color to blue. Only the last member of the array turns to blue color
Emulator screenshot. I tried using both spannableString and SpannableStringBuilder, but I’m probably doing something wrong as I’m new to the language. The array is filled correctly, as I tested it.
Function code