barcodereader
barcodereader

Reputation: 2038

Android EditText how to start cursor pointer at the end of all characters- not end of first line

I have comment box using EditText and it has several lines. When user returns to the box they are always at end of line 1 rather than end of say line 3 if there are three lines total in the box. How can I fix this?

Upvotes: 3

Views: 7243

Answers (2)

maruti060385
maruti060385

Reputation: 797

You can also do this
final int selectionStart = editText.getSelectionStart(); final int selectionend = editText.getText().length();

Selection.setSelection(editText.getText(), selectionStart, selectionend);

Please make you are not calling setText after this because that will override the behavior.

Upvotes: 0

Aleadam
Aleadam

Reputation: 40391

There might be easier ways perhaps, but one way is to use

editText.setSelection(editText.getText().length());

You can place this line inside an OnFocusChangeListener, or in a Create method.

Upvotes: 14

Related Questions