I have searched internet and tried the following code but its not working
SpannableString ss1 = new SpannableString(\"Health: \");
ss1.setSpan(new and
In kotlin, you can do this. I used this to bold characters/word within a string. For example:
item = "Philippines"
query = "Phil"
result = Philippines
val spannable = SpannableString(item)
val indexStart = item.indexOf(query)
val indexEnd = indexStart + query.length
spannable.setSpan(StyleSpan(Typeface.BOLD), indexStart, indexEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
and use it like this
textView.text = spannable