Shabbir Panjesha
Shabbir Panjesha

Reputation: 1939

Android Keyboard not showing

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.

Upvotes: 1

Views: 2682

Answers (1)

Ricky
Ricky

Reputation: 7879

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.

Upvotes: 7

Related Questions