Can I place the cursor at the end of the text in EditText?

Asked 1 years ago, Updated 1 years ago, 89 views

When changing the value of EditText in the keyListener There's a cursor at the beginning of EditText, and I want to put it at the end of the text. How do I move the cursor to the end?

android keylistener android-edittext

2022-09-21 18:23

1 Answers

EditText et = (EditText)findViewById(R.id.inbox);
et.setSelection(et.getText().length());

Write setSelection(). It's a method to move the position of the cursor, and et.getText returns the text of et length() means to return the length of the text. So this will move the cursor to the end of the text.


2022-09-21 18:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.