开发者

Android EditText's cursor position tracking when clicking or toching by first time itself

开发者 https://www.devze.com 2023-03-01 07:00 出处:网络
i am struggling with EditText for morethan a day. My goal is to know current cursor positon that user\'s first click on the EditText.

i am struggling with EditText for morethan a day. My goal is to know current cursor positon that user's first click on the EditText.

  1. Assume current cursor at po开发者_如何学Csition "5",
  2. Click EditText widget at position "8",
  3. At this moment getSelectionStart() retrieve previous value say "5".
  4. Click EditText widget at position "8" again,
  5. getSelectionStart() retrieve the position become "8", (This is correct, but need click twice at same position)
  6. Click on a new position, situation will repeat Step3.


Just try:

   getSelectionEnd() 

(If your action doesn't contain selecting a range of text.)

0

精彩评论

暂无评论...
验证码 换一张
取 消