GetEditableText () returns null for me. Instead, to add text to the spannable, I set the buffer buffer type to SPANNABLE: in the code:
myTextView.setText(myText, TextView.BufferType.SPANNABLE);
or using the xml property android: bufferType in your TextView.
Then drag getText () to Spannable, after which I finish the additional text with the existing text:
Spannable currentText = (Spannable) tvTitle.getText(); CharSequence indexedText = TextUtils.concat(String.format("%d. ", index), currentText); myTextView.setText(indexedText);
As far as I can tell, all functions are available from API level 1.
source share