I'm developing an android application which contains an EditText
.
I control what is written in the editText by calling
et.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
String message = et.getText().toString();
if(s.toString().compareTo(before)!=0){
et.setText(message);
et.setSelection(et.getText().length());
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
before = et.getText().toString();
System.out.println("After");
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
System.out.println("ON");
}
});
In afterTextChanged function I use et.setText("some Text");
the problem is that,after the text is changed the keyboard also changed,for example if the symbol
keyboard was opened and I used setText, it will automatically changed to qwerty
.
How can I solve this problem?