Nidhi
Nidhi

Reputation: 699

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.

Upvotes: 3

Views: 1077

Answers (2)

user2663613
user2663613

Reputation: 52

use android:paddingLeft= "2dp"

Upvotes: 1

kalyan pvs
kalyan pvs

Reputation: 14590

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);

Upvotes: 4

Related Questions