Get Cursor Position in Android in Edit Text?

Solution 1:

You can get the Cursor position using the getSelectionStart() and getSelectionEnd() methods. If no text is highlighted, both getSelectionStart() and getSelectionEnd() return the position of the cursor. So something like this should do the trick:

myEditText.getSelectionStart();

or

myEditText.getSelectionEnd();

Then if you want to select all the text after the cursor you could use this:

int cursorPosition = myEditText.getSelectionStart();
CharSequence enteredText = myEditText.getText().toString();
CharSequence cursorToEnd = enteredText.subSequence(cursorPosition, enteredText.length());