Alex Bigalo
Alex Bigalo

Reputation: 41

EditText/TextWatcher brings me back to the beginning of the input line

public void afterTextChanged(Editable s) {
    if (editText.getText().length() == 12) {
        editText.setText(editText.getText().subSequence(0, editText.getText().length() - 1));
    }

    //problem in this part of code
    if (editText.getText().length() == 2 || editText.getText().length() == 5 || editText.getText().length() == 8) {
        editText.setText(editText.getText()+"/");
    }
}    

How can I go back to the end of the input line?

Upvotes: 0

Views: 35

Answers (1)

fchristysen
fchristysen

Reputation: 208

You could add this at the end of your method:

editText.setSelection(editText.getText().toString().length());

PS: Would be better if you describe more about your problem, so it would be easier to understand. :)

Upvotes: 1

Related Questions