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:



editText.setSelection(editText.text.toString().length)//placing cursor at the end of the text



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();



Powered by emlog 京ICP备15036472号-3 sitemap