I have the following code:
@SuppressWarnings("unchecked")
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
data = (ArrayList<SetRows>)results.values;
EditText etS = (EditText) ((Activity)context).findViewById(R.id.etSearch);
if (data.isEmpty()) {
etS.setTextColor(Color.parseColor("#FFCC0000"));
Vibrator vb = (Vibrator) ((Activity)context).getSystemService(Context.VIBRATOR_SERVICE);
// Vibrate for 100 milliseconds
vb.vibrate(100);
}
if (!data.isEmpty()) {
etS.setTextColor(Color.parseColor("#FF27497B"));
}
notifyDataSetChanged();
clear();
for(int i = 0, l = data.size(); i < l; i++)
add(data.get(i));
notifyDataSetInvalidated();
}
It vibrates every time I enter a character which doesn't match anything in the ListView
and it's working fine. The issue is, it also vibrates when I press the backspace/delete key. Which is not the intention.
How do I allow the vibrate while entering the wrong letter, but not when pressing backspace/del key. I tried the onTextChanged
but that wasn't working.