【发布时间】:2012-01-09 09:17:55
【问题描述】:
我遇到了一个问题。当我登录我的应用程序(从登录页面到主页)时,主页中没有任何可编辑的小部件,但键盘会自动弹出,我不想这样做, 如何解决?谢谢
【问题讨论】:
标签: android android-widget android-manifest
我遇到了一个问题。当我登录我的应用程序(从登录页面到主页)时,主页中没有任何可编辑的小部件,但键盘会自动弹出,我不想这样做, 如何解决?谢谢
【问题讨论】:
标签: android android-widget android-manifest
来自Close/hide the Android Soft Keyboard:
您可以强制 Android 使用 InputMethodManager,调用 hideSoftInputFromWindow,传入 包含您的编辑字段的窗口的标记。
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);这将强制键盘在所有情况下都隐藏。在一些 您想要传递的案例
InputMethodManager.HIDE_IMPLICIT_ONLY作为第二个参数,以确保您仅在 用户没有明确地强制它出现(通过按住菜单)。
【讨论】:
试试这个。
InputMethodManager inputManager = (InputMethodManager) (YourActivity)
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(home.getCurrentFocus()
.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
【讨论】: