I've implemented an app with a NavigationDrawer and some Fragments. But everytime I change Fragment with the NavigationDrawer, the soft keyboard keeps popping up, even if there's no EditText on the screen.
How can I solve this?
您是否尝试过将其添加到活动清单中:
android:windowSoftInputMode="stateHidden"
Add this line of code in your activity
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
And try with adding to fragment also.
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
Try This in your BaseActivity or Main Activity
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
View view = this.getCurrentFocus(); if (view.= null) { InputMethodManager imm = (InputMethodManager) getSystemService(Context;INPUT_METHOD_SERVICE). imm.hideSoftInputFromWindow(view,getWindowToken(); 0); }
This helped me out. I hope it works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.