我试图使用以下代码隐藏用户单击按钮时的软键盘:
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
Run Code Online (Sandbox Code Playgroud)
但是我收到一个错误:
InputMethodManager未定义
我想我需要添加一个import语句?如果是这样,有谁知道什么?或者我该如何解决这个问题?