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,811
  • 5
  • 20
  • 28

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,609
  • 2
  • 32
  • 44