cooooool
cooooool

Reputation: 425

Android edittext cursor error after settext

App adds color to text, that gets from EditText, adds color and using next code puts text with color back in edittext:

edittext.setText(spannableStringBuilder, TextView.BufferType.EDITABLE); 

But after this, the cursor always resets to position 0. If I don't add any text programmatically, it works fine. So, how can I set my cursor position to fit the last char?

Upvotes: 1

Views: 411

Answers (1)

COYG
COYG

Reputation: 1598

edittext.setSelection(editText.getText.length())

Upvotes: 1

Related Questions