I have the same problem. And suppose there is no good way to implement one solution to handle soft keyboard events. I implemented the onKeyListener() event for delete event and TextWatcher for key events.
m_edtRecipients.addTextChangedListener(new TextWatcher() { boolean bConsumed = false; @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!bConsumed) { RecipientsTextStyle.format(m_edtRecipients.getText(), m_dbProcessor); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (count != 0) { bConsumed = true; Log.d(TAG, "delete true"); } else { bConsumed = false; Log.d(TAG, "erase false"); } } @Override public void afterTextChanged(Editable s) { } });
There is one big drawback to the TextWatcher approach — you cannot change the editable associated with your EditText — this will cause a loop. Be careful!
source share