From the android tutorial :
pass_text.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
// If the event is a key-down event on the "enter" button
if ((event.getAction() == KeyEvent.ACTION_DOWN)
&& (keyCode == KeyEvent.KEYCODE_ENTER)) {
// Perform action on key press
return true;
}
return false;
}
});
}
when click at EditText, it has a keyboard appear on the frame. I want to know after Enter. How to make keyboard out from frame except click Back.
Thank you
Try the following
For Activity:
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(curEditText.getWindowToken(), 0);
In case of Fragment :
InputMethodManager mgr = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
give the EditText
box you have the attribute android:imeOptions="actionDone"
this will change the Enter button to a Done button that will close the keyboard.
A working approach to get rid of the soft keyboard is to disable and then enable the TextEdit field in the Return-key event, button-press event or whatever. For example:
....
pass_text.setEnabled(false);
pass_text.setEnabled(true);
....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With