Hide Soft Keyboard on Done Keypress in Android?
Use android:imeOptions="actionDone", like that:
<EditText
...
android:imeOptions="actionDone" />
Changed the if-statement to if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)
made it working with the xml-attribute android:inputType="phone"
.
InputMethodManager inputManager = (InputMethodManager)
context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.toggleSoftInput(0, 0);
with context being your activity.