androidspannablecharsequence

How to merge some spannable objects?


I divide a spannable object into 3 parts, do different operations, and then I need to merge them.

Spannable str = editText.getText();
Spannable selectionSpannable = new SpannableStringBuilder(str, selectionStart, selectionEnd);
Spannable endOfModifiedSpannable = new SpannableStringBuilder(str, selectionEnd, editText.getText().length());
Spannable beginningOfModifiedSpannable = new SpannableStringBuilder(str, 0, selectionStart);            

How can I do it? I haven't found the required method or constructor to do it.


Solution

  • You could use this:

    TextUtils.concat(span1, span2);
    

    http://developer.android.com/reference/android/text/TextUtils.html#concat(java.lang.CharSequence...)