Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

different of setText(CharSequence,TextView.BufferType) and setText(CharSequence)

Tags:

java

android

what is difference between setText(CharSequence, TextView.BufferType) and setText(CharSequence), and when we should use them?

like image 694
Erfan Eghterafi Avatar asked Nov 01 '22 05:11

Erfan Eghterafi


1 Answers

setText (CharSequence text)

Sets the string value of the TextView. whereas

setText (CharSequence text, TextView.BufferType type) 

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

All BufferType options are:

  1. TextView.BufferType.EDITABLE
  2. TextView.BufferType.NORMAL
  3. TextView.BufferType.SPANNABLE

for e.g.

myEditText.setText("This is new text from setText with BufferType EDITABLE.",  TextView.BufferType.EDITABLE); 
like image 114
Giru Bhai Avatar answered Nov 12 '22 12:11

Giru Bhai