xiaodouya
xiaodouya

Reputation: 87

softkeyboard pop up while there are no editable widgets?

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

Upvotes: 1

Views: 128

Answers (2)

user647826
user647826

Reputation:

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

Upvotes: 1

san
san

Reputation: 1835

Try this.

InputMethodManager inputManager = (InputMethodManager) (YourActivity)
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    inputManager.hideSoftInputFromWindow(home.getCurrentFocus()
                            .getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);

Upvotes: 0

Related Questions