I added setOnKeyListener for Enter keyevent. However, adding setOnKeyListener, the delete (backspace) key does not work. When I deleted setOnKeyListener, the delete key works fine.
How to fix delete key works well?
final EditText edittext = (EditText) findViewById(R.id.editText1); edittext.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View arg0, int arg1, KeyEvent event) { // TODO Auto-generated method stub if (event != null&& (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); in.hideSoftInputFromWindow(edittext .getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); applySearch(); } return true; } });
source share