隐藏虚拟键盘,当点击一个按钮按钮、键盘

2023-09-05 09:30:19 作者:花落莫相离

有没有一种方法可以隐藏虚拟键盘当我点击Android的一个按钮?键盘最初弹出当用户触摸一个EditText分量;我想它关闭,一旦一个按钮被按下。

Is there a way to hide the virtual keyboard once I click a button in android? The keyboard originally pops up when the user touches an edittext component; I'd like it to close once a button is pushed.

推荐答案

要隐藏虚拟键盘尝试/使用此

To hide virtual keyboard try/use this

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(medtSearchQuery.getWindowToken(), 0);