How to control text in edittext with textwatcher <p>So I'm trying to make user insert text with some format that should be xx.xxxx. For that I'm using textwatcher class. Here is my class:</p> <pre><code>edittext.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { EditText edittext = (EditText) findViewById(R.id.my_edit); if(edittext.getText().length()==2)edittext.setText(edittext.getText().toString()+"."); } }); </code></pre> <p>So i basicly just add '.' if length after editing is 2. But after i do that it set my cursor to start of the text field and when i try to delete dot it just recreate it because length is again 2. I know there is some solution but it seems i can't figure it out today :S</p>