Case 1:If you want close keyboard on open of dialog fragment
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View view = super.onCreateView( inflater, container, savedInstanceState );
//to hide keyboard when showing dialog fragment
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
return view;
}
case 2:If you want close keyboard on selection autocompletetext or any other edit text view use simple
public static void hideDialogFragmentKeyboard(Context context,View view) {
view.postDelayed(new Runnable() {
@Override
public void run() {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}, 100);
}
I think this will work