question: public static Spannable createSpannableFromTextWithTemplate ( String text , CharSequence innerTemplate ) { SpannableString result = new SpannableString ( text ) ; if ( innerTemplate instanceof Spanned ) { int index = text . indexOf ( innerTemplate . toString ( ) ) ; if ( index >= 0 ) { copySpans ( result , ( Spanned ) innerTemplate , index ) ; } } return result ; }
target:  Create spannable from text that includes some CharSequence. If the CharSequence has any spans they would be copied to result spannable