I\'m making an app with edittext and a button. When I enter something into edittext and then click a button, I want the keyboard and focus on edittext to disappear but I can\'t
First you must disable the keyboard:
void hideKeyboard(Activity activity) {
View view = activity.getCurrentFocus();
InputMethodManager manager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
assert manager != null && view != null;
manager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
Second clear view (Layout, EditText...)focus:
view.clearFocus