0

I know that if binding is not applied, then I can use Textview.setText(ClickableSpan) to apply spannig effect to make part of the text clickable. However, my app used binding and the textview's text is binded to a ViewModel inside xml like android:text="@{model.certainString}" and in the ViewModel I declared String certainString = "", in this case how do I apply spanning inside the ViewModel then?

litaoshen
  • 1,762
  • 1
  • 20
  • 36

1 Answers1

0

You could write your own BindingAdapter which accepts either the model or the string value, within the Adapter code you would then be able to apply a Spannable.

https://developer.android.com/reference/android/databinding/BindingAdapter.html

Chris
  • 2,332
  • 1
  • 14
  • 17