I am showing a dialog with an edittext view. However, the soft keyboard will open only if the user clicks on the edit. So I tried calling InputMethodManager with the following code.
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(dialogField,0);
The dialog box is an input field. However, when should I do this? I tried it in the onStart () method of the dialog, but nothing happens. I also tried to request focus for dialogField before, but that doesn't change anything.
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); } } });
in both versions. But no soft keyboard would like to appear. Main.log is just a log that shows me that the function is actually called. And yes, thatβs called.
I can get the keyboard with the symbol SHOW_FORCED before opening the dialog box. But then it will not close when exiting. And I can do this only before I show the dialogue. Inside any callbacks this doesn't work either.
Rene Nov 23 '10 at 16:56 2010-11-23 16:56
source share