• Post Reply Bookmark Topic Watch Topic
  • New Topic

Edittext cursor position

 
asha Pawaskar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

How to get the cursor position in the editText and how to add a character at that position?

I have tried with Selection class but no use because it has methods like getSelectionStart() and getSelectionEnd().

I want to get the position of the cursor?
 
Ankit Garg
Sheriff
Posts: 9597
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there is no selection, both getSelectionStart and getSelectionEnd return the position of the cursor in the EditText. To insert something at the current cursor position, use
 
asha Pawaskar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Ankit

Thanks, it's working.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!