Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit text cursor position

I want to place the cursor after 2 spaces in EditText. Can anybody tell me how to do that? I am trying to use

et.setSelection(2);

but its not working.

like image 445
Nidhi Avatar asked May 12 '26 23:05

Nidhi


1 Answers

Try to use like this..before set the the cursor position there must be some text at the starting there is no text that's why it is not working.. so try like this..

et.setText("   ");
et.setSelection(2);
like image 66
kalyan pvs Avatar answered May 15 '26 11:05

kalyan pvs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!