Win a copy of hapi.js in Action this week in the HTML, CSS and JavaScript forum!
  • 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: 9587
33
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!