1

I'm showing an input box using AlertDialog. The EditText inside the dialog itself is automatically focused when I call AlertDialog.show(), but the soft keyboard is not automatically shown.

How do I make the soft keyboard automatically show when the dialog is shown? (and there is no physical/hardware keyboard). Similar to how when I press the Search button to invoke the global search, the soft keyboard is automatically shown.

Shabbir Panjesha
  • 1,851
  • 5
  • 20
  • 29

1 Answers1

7

You could try the following method once the dialog is open, taken from here:

InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.toggleSoftInputFromWindow(linearLayout.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);

Other suggestions here too.

Community
  • 1
  • 1
Ricky
  • 7,785
  • 2
  • 34
  • 46