0

I have an edit text in my layout. After some user operations, I want to check if the cursor position is the first position or at any other position. how to do that?

Sam
  • 7,252
  • 16
  • 46
  • 65
S P
  • 854
  • 4
  • 10
  • 21

1 Answers1

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 you can do something like:

yourEditText.getSelectionStart();

or

yourEditText.getSelectionEnd();
  • thanks ..... one more thing, how to determine if the user has pressed the 'delete' key or long pressed it. – S P Sep 04 '13 at 11:00
  • You may refer to [this](http://stackoverflow.com/a/13382981/2003486) answer for setting a long click listener. –  Sep 04 '13 at 11:13