Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android edittext - settextmethod cursor issue

I am trying to settext in an EditText...But after setText is done, the cursor remains at the start of text.how can i move it to the end of the text?

Any help in this regard is appreciated.

Best Regards, Rony

like image 461
user264953 Avatar asked Feb 28 '11 12:02

user264953


People also ask

How do I change the cursor position in EditText?

Say in your xml's edittext section, add android:paddingLeft="100dp" This will move your start position of cursor 100dp right from left end. Same way, you can use android:paddingRight="100dp" This will move your end position of cursor 100dp left from right end.

What is the difference between EditText and TextView?

EditText is used for user input. TextView is used to display text and is not editable by the user. TextView can be updated programatically at any time.


2 Answers

EditText inputField;
Editable etext = inputField.getText();
int position = etext.length();
inputField.setSelection(position);
like image 115
Pasha Avatar answered Oct 04 '22 21:10

Pasha


Use append(CharSequence text). This will also update the position of the cursor. See Android Documentation

like image 45
Codemonkey Avatar answered Oct 04 '22 22:10

Codemonkey