In EditText
where I want to add a letter counter. it counts properly but when I entered backspace it's also considered as a letter and count added by 1 which actually should be decremented by 1. my code is
text_feedback_text.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable s)
{
int keyCode = 0;
if(keyCode==KeyEvent.KEYCODE_DEL){
i--;
Log.d("back","backspace pressed"+i);
}else
i++;
text_feedback_count.setText(String.valueOf(i) + " / " + String.valueOf(charCounts));
}
public void beforeTextChanged(CharSequence s, int start, int count, int after){}
public void onTextChanged(CharSequence s, int start, int before, int count)
{
text_feedback_count.setText(String.valueOf(s.length()));
}
}
);
Please help me out when i clicking backspace its not detecting and also not printing on logcat.
Please reply if anybody have some clue.
Thank you!