setText (CharSequence text, TextView.BufferType type) - android:bufferType - TextView

setText (CharSequence text, TextView.BufferType type) was added in API Level 1

Sets the text that this TextView is to display (see setText(CharSequence)) and also sets whether it is stored in a styleable/spannable buffer and whether it is editable.

1. Find a TextView using ID

2. In the MainActivity.java file, add the code below to the onCreate method 

myEditText.setText("This is new text from setText with BufferType EDITABLE.",  TextView.BufferType.EDITABLE); 

3. All BufferType options:

TextView.BufferType.EDITABLE
TextView.BufferType.NORMAL
TextView.BufferType.SPANNABLE


4. Compile and run!

5. There is a bug in Android that a TextView will not reset the size the font size is decreased. This fixes the problem. (workaround for Android bug #17343 and #22493)

myTextView.setText(myTextView.getText(),TextView.BufferType.SPANNABLE);

Related Articles:

Resources: