Android disable keyboard display on dialog.show

Is there a way to prevent the keyboard from appearing when a dialog appears.

here is my code for my dialog box

final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.shopping_cart_confirm_dialog); TextView txtConfirmEmail = (TextView)dialog.findViewById(R.id.txtConfirmEmail); ... dialog.show(); 

Thank you very much.

+4
source share
2 answers

try it

 dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); 
+10
source

Using InputMethodManager , you can hide the keyboard.

Check hideSoftInputFromWindow . It takes a window that returns

 View.getWindowToken() InputMethodManager mgr=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(dialog.getWindow().getWindowToken(), 0); 
0
source

All Articles