closeSoftKeyboard(myEditText);
...
}
private void closeSoftKeyboard(View view) {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
getActivity() is needed when you use it in Fragment.