1. Resolve Unable to eject input method:
Before the show () method call, add an empty EditText with Dialog.setview (new EditText), because the custom Alertdialog has the layout we specify, so setting this does not affect our functionality, So you can pop up the input method ...
2. The input method can be popped, but in order to enhance the user experience, when the dialog contains edittext should be, in the display dialog the same time automatically eject the keyboard:
(1) The following methods can be added to the custom dialog:
public void Showkeyboard () {if (edittext!=null) {//set can get focus edittext.setfocusable (TRUE); Edittext.setfocusableintouchmode (TRUE);//request to get focus edittext.requestfocus ();//Call system input Inputmethodmanager InputManager = (Inputmethodmanager) edittext.getcontext (). Getsystemservice (Context.input_method_service); Inputmanager.showsoftinput (editText, 0);}}
where EditText is the view of the input box in the custom dialog
(2) after Dialog.show (), call this method to display the IME, because in the call May dialog interface is not loaded complete, editText may also be empty, so need to add a delay task, delay display:
Dialog.show (); Timer timer = new timer (), Timer.schedule (new TimerTask () {@Overridepublic void run () {Dialog.showkeyboard ();}}, 200);
EditText in custom dialog in Android cannot eject IME solution