0

I multiple strings in the following format.
- "the *quick* brown fox *jumps* over the lazy *dog* " I want to show them as
- "the quick brown fox jumps over the lazy dog "

in a recyclerview adapter how can that be done I have no clue how to begin.

Pemba Tamang
  • 458
  • 3
  • 16
  • if you search `Make multiple parts of string bold` your first result should be this : https://stackoverflow.com/questions/14371092/how-to-make-a-specific-text-on-textview-bold/14371107, does that help ? – a_local_nobody Jan 27 '20 at 11:26
  • I kinda see the steps I have to find all the indexes of *. if the *'s exist I need to make the text b/w the indexes bold and remove the * themselves. seems it will slow down the app is there a good example how that can be done?? – Pemba Tamang Jan 27 '20 at 11:32

1 Answers1

1

You need to use SpannableString

val spannableString = SpannableString("Here this is for span string example!")
val loc = spannableString.toString().indexOf("s")
spannableString.setSpan(ForegroundColorSpan(Color.RED), loc, 3, 
Spannable.SPAN_INCLUSIVE_EXCLUSIVE)
hint_textView!!.setText(spannableString.toString())
Rohit Soni
  • 1,300
  • 6
  • 12