The input method solution cannot be displayed for EditText in the Custom dialog, dialogedittext

Source: Internet
Author: User

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); 

  

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.