我遇到一个问题。当我登录我的应用程序时(从登录页面到主页),主页中没有任何可编辑的小部件,但键盘会自动弹出,我不想这样做, 如何解决?谢谢
最佳答案
来自 Close/hide the Android Soft Keyboard :
You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow, passing in the token of the window containing your edit field.
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
This will force the keyboard to be hidden in all situations. In some cases you will want to pass in
InputMethodManager.HIDE_IMPLICIT_ONLY
as the second parameter to ensure you only hide the keyboard when the user didn't explicitly force it to appear (by holding down menu).
关于android - 没有可编辑的小部件时弹出软键盘?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8786102/