I have following code for my edittext formatting, since it can take any input I am not setting any input type:
if (cardNumberEditText != null) {
cardNumberEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
int currSel = cardNumberEditText.getSelectionStart();
cardNumberEditText.removeTextChangedListener(textWatcher);
.
.
cardNumberEditText.setText(formattedNumber);
.
.
cardNumberEditText.setSelection(currSel);
cardNumberEditText.addTextChangedListener(textWatcher);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
So initially I get the default input type which is ABC, now when I change it to ?123 (using ABC/123? toggel button) and after entering some number the keyboard changes back to ABC. This code seams to work fine on samsung devices s3 and sywpe but not on nexus with L and HTC one
When I comment all the code inside onTextChanged, it works fine. So when I investigated I found out that culprit is cardNumberEditText.setText(formattedNumber);
I am not setting any input type, I am just using the ABC/?123 toggle key on keyboard for switching
Any help/suggestion why this is happening (on few devices) and how can I correct it ??