The input method solution cannot be displayed for EditText in the Custom dialog, dialogedittext
1. the pop-up input method cannot be solved:
Before calling the show () method, use dialog. setView (new EditText (context) adds an empty EditText. Because it is a custom AlertDialog and has a specified layout, setting this will not affect our functions, in this way, the input method will pop up ......
2. The input method can be displayed. However, to enhance user experience, when the dialog contains editText, the keyboard is automatically displayed while the dialog is displayed:
(1) You can add the following methods to the custom dialog:
Public void showKeyboard () {if (editText! = Null) {// you can obtain the focus editText. setFocusable (true); editText. setFocusableInTouchMode (true); // The request obtains the focus editText. requestFocus (); // call the system input method InputMethodManager inputManager = (InputMethodManager) editText. getContext (). getSystemService (Context. INPUT_METHOD_SERVICE); inputManager. showSoftInput (editText, 0 );}}
EditText is the view of the input box in the Custom dialog.
(2) In dialog. show:
dialog.show(); Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { dialog.showKeyboard(); } }, 200);