我已经在 EditText 上应用了 OnKeyListener() 并且它不适用于三星 Galaxy S3,但适用于所有其他手机......不知道我做错了什么......
et = (EditText) findViewById(R.id.editText1);
et.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View arg0, int keyCode, KeyEvent arg2) {
// TODO Auto-generated method stub
// You can identify which key pressed buy checking keyCode value
// with KeyEvent.KEYCODE_
if (keyCode == KeyEvent.KEYCODE_DEL) {
// this is for backspace
Log.d("Button Event", "BackSpace Pressed");
if (et.getSelectionStart() < length + 1) {
return true;
} else {
return false;
}
}
return false;
}
});