Place cursor at the end of text in EditText
2021-6-3 anglehua
I am changing the value of an EditText
on keyListener
.
But when I change the text the cursor is moving to the beginning of the EditText
.
I need the cursor to be at the end of the text.
How to move the cursor to the end of the text in a EditText
.
Try this:
UPDATE:
Kotlin:
editText.setSelection(editText.text.toString().length)//placing cursor at the end of the text
Java:
editText.setSelection(editText.getText().length());
There is a function called append for ediitext which appends the string value to current edittext value and places the cursor at the end of the value.
You can have the string value as the current ediitext value itself and call append();
myedittext.append("current_this_edittext_string");
采集自互联网,如有侵权请联系本人