Update: actually, this is not a problem with Asus Phones, it's a problem with Asus ZenUI's keyboard. You can install a keyboard you like to walk around the problem. I have tested Zenfone 2 with Google Keyboard installed. Everything in my TextWatcher
works fine. But it is not a bug fix or problem solution.
I have two InputFilter
s and one TextWatcher
attached to my EditText
.
InputFilters
: standard InputFilter.AllCaps()
filter and custom 'alphabet characetrs only'. They works as magic.
TextWatcher
makes some text transofrmations (transliterates symbols from Russian into English). TextWatcher
also works fine but not on Asus phones (tested on Zenfone 4 and 5). Nexus 5, Genymotion emulator and Samsung device is OK.
The problem is that Asus phone not allows to enter more than one symbol. Probably, there is a problem with TextWatcher
or setSelection()
(everything works fine on Asus when TextWatcher
is disabled).
Listing for TextView
:
etCardholder.setFilters(new InputFilter[]{new InputFilter.AllCaps(), new NameInputeFilter(false)});
twTransliterator = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
etCardholder.removeTextChangedListener(twTransliterator);
etCardholder.setText(StringTools.transliterateCharacterRuToEn(s.toString()));
etCardholder.addTextChangedListener(twTransliterator);
}
@Override
public void afterTextChanged(Editable s) {
etCardholder.setSelection(etCardholder.getText().length());
validateCardData();
}
};
etCardholder.addTextChangedListener(twTransliterator);
I've tried not to set cursor's position with setSelection()
, but use append()
instead. Same results here.
Do you have any ideas what probably it can be? And how to walk around it?