Closed umerk44 closed 3 years ago
I am facing that too. Please fix this
Please fix this and Let me know
You'll have to elaborate what the issue is because I am unable to recreate it.
textView.setText(SpannableString.valueOf("Hello #there"))
I have the same issue. What I want to do is apply a span to a text that is going to show up inside a SocialTextView. For example:
Username_here Hello @someone and good morning to @someone_else.
I want to make the "Username_here" part of the string be bold (which I can do via a Spannable) and the rest of the text (Hello @someone and good morning to @someone_else) to behave like it should since it is a SocialTextView (meaning being able to handle clicks on mentions and links).
Trying something like this:
val postTitle = item.customerInfo.name + " " + item.caption
var spannable = SpannableString(postTitle)
Timber.d("setting span from %d to %d (%s)", 0, item.customerInfo.name.length, spannable.toString())
spannable.setSpan(ForegroundColorSpan(Color.RED), 0, item.customerInfo.name.length, Spannable.SPAN_EXCLUSIVE_INCLUSIVE)
binding.postTitle.text = spannable
doesn't make the item.customerInfo.name part to be red.
Any ideas what we can do to solve this issue?
@SotirisAtSeb this is quite different from the author's question.
What you can do at the moment is add your own TextWatcher
with addTextListener
. Put your code that spans red in afterChange
. I will gladly continue the discussion and provide code sample if you're still having issues.
But back on topic, this issue is closed due to inactivity.
Hi, i tried what you suggested about adding a Textwatcher and doing the manip in afterTextChanged, unfortunately it doesn't work ! I have the exact same problem that @SotirisAtSeb Any solution to it ? Thx
@samuel2629 post me your TextWatcher
code snippet.
I've a SpannableString which I'm setting with .setText(spannableString) but it's updating spans. Same string would work with other views, like TextView, EditTextView.