I would like to highlight all of the substring which are inside square brackets, ex: "[Toto] is [doing a lot of] stuff at the same time."
I know how to extract it.
I know how to highlight:
val str = SpannableString("Toto is doing a lot of stuff at the same time.")
str.setSpan(BackgroundColorSpan(Color.YELLOW), 0, 4, 0)
str.setSpan(BackgroundColorSpan(Color.YELLOW), 8, 22 , 0)
textView.text = str
But the problem is I don't know how to achieve both together.
I obviously want to remove the square bracket after have applied the highlight effect but when I do a toString() then a replace() the highlight is removed.
Also, the highlight is made with index, and I don't want to extract the substring but let it in the original string, I don't know by which optimized way I should achieve that.
