androidandroid-edittextinput-filter

Input Filter Interface with Source as Spanned or Spannable


I was going through reference document of Input Filter from the link http://developer.android.com/reference/android/text/InputFilter.html There is a mention that if source is an instance of Spanned or Spannable, the span objects in the source should be copied into the filtered result (i.e. the non-null return value). Can someone explain me the usefulness and meaning of this line.I have implemented Input Filter in my code and the source is neither spanned nor spannable.


Solution

  • Short answer -- if your source isn't spannable then you don't need to worry about this.

    Long answer -- if your source is spannable, that means that besides text it has spans, i.e. certain areas of it marked with some attribute. An example is a string of which the first word is in bold. In this case if you don't take care of the spans as well as the text, you'll lose all special attributes.