I am displaying a dialog with an edittext view. However, the softkeyboard will open only if the user presses inside the editview. So I tried calling an InputMethodManager with the following code.
InputMethodManager imm =
(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(dialogField,0);
The dialogField is the input field. However, when exactly am I supposed to do this? I tried it in the onStart() method of the dialog, but nothing happens. I also tried requesting the focus for the dialogField before, but that changes nothing.
I also tried this code
dialogField.setOnFocusChangeListener(new View.OnFocusChangeListener()
{
public void onFocusChange (View v, boolean hasFocus)
{
if (hasFocus)
{
Main.log("here");
dialogInput.getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
/*
InputMethodManager mgr =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(dialogField,0);
*/
}
}
});
in both versions. But no soft keyboard would like to appear. The Main.log is just a log, which shows me that the function is actually called. And yes, it is called.
I could get the keyboard with the SHOW_FORCED flag before the dialog opens. But then it will not close on exit. And I can only do that BEFORE I show the dialog. Inside any callbacks it does not work either.