I am using TextWatcher and I am unable to detect Backspace key in TextWatcher.afterTextChange event. I also want to clear textView on some condition in textWatcher event.
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
// I want to detect backspace key here
}
A
KeyListenercan fulfil both of your conditions.Similarly inside the
onKey(), you can put multiple check statements to check for the condition, when you would want to clear thetextView.EDIT : As @RankoR was kind enough to point out, please bear in mind that
onKeyListener()works only for the hardware keyboards and not the soft keyboards.