Reputation: 902
So I have an EditText
with the inputType
as numberDecimal
(I don't think this matters but whatever)... I want it so that when I press and hold the backspace key (longpress) all the numbers in the EditText
are deleted at once instead of rapidly one at a time as is the current behavior. Is this possible? The only thread I could find about this issue is this but I tried implementing that solution (overriding onKeyLongPress())
and that method never gets called.
Upvotes: 0
Views: 356
Reputation: 845
editText.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
//You can identify which key pressed buy checking keyCode value with KeyEvent.KEYCODE_
if(event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
//this is for backspace
}
return false;
}
});
Upvotes: 1