如何隐藏Android软键盘?

shw*_*ain -5 android android-softkeyboard android-edittext android-virtual-keyboard

我在Linearlayout中有两个EditText视图和一个Button.完成edittext中的写入后,我想隐藏Android虚拟键盘,我该怎么做?

Luc*_*fer 17

您可以像这样使用InputMethodManager类:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow( yourEditText.getWindowToken(),InputMethodManager.RESULT_UNCHANGED_SHOWN);
Run Code Online (Sandbox Code Playgroud)