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:
[Java]View Plain Copy
- Public void Showkeyboard () {
- if (edittext!=null) {
- //Set to get focus
- Edittext.setfocusable (true);
- Edittext.setfocusableintouchmode (true);
- //Request for 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:
[Java]View Plain Copy
- Dialog.show ();
- Timer timer = new timer ();
- Timer.schedule (new TimerTask () {
- @Override
- public Void Run () {
- Dialog.showkeyboard ();
- }
- }, 200);
EditText in custom dialog in Android cannot eject IME solution