1

I meet a problem.when i login my app(from login page to home page),there is no any editable widgets in home page,but the keyboard pops up automatically which i dont want to , how to fix it? thanks

xiaodouya
  • 87
  • 1
  • 11

2 Answers2

1

From 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).

Community
  • 1
  • 1
0

Try this.

InputMethodManager inputManager = (InputMethodManager) (YourActivity)
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    inputManager.hideSoftInputFromWindow(home.getCurrentFocus()
                            .getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
san
  • 1,872
  • 13
  • 22