I have an EditText
that I need to ignore Backspace keyEvents. I have the following class, but it doesn't work:
public class CustomEditText extends EditText {
public CustomEditText(Context context, AttributeSet attrs) {
super(context);
// TODO Auto-generated constructor stub
this.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(keyCode == KeyEvent.KEYCODE_DEL){
//do nothing
}
return true;
}
});
}
}