Android Development solves the problem that edittext in Alertdialog cannot recall input method

Source: Internet
Author: User

Using a custom view in Alertdialog, if the view has EditText, click on it, the default is not to jump out of the soft keyboard, not the focus of the problem.
Solution, there are two, one is to change the Alertdialog to dialog, but so that the outermost layer of the dialog box will be more than a box, the top will be empty dozens of DP, of course, you can use Setbackgrounddrawable (new colordrawable (0)) Set the background to transparent, hide the border, but the above dozens of of the empty DP is still there, the dialog box is not centered on the screen.
Code:

New= Ad.getwindow (); window.setbackgrounddrawable (new colordrawable (0 )); Window.setcontentview (r.layout.cancel_sos_dialog);

The best way to do this is the second type:

New= Ad.getwindow (); Window.setcontentview (Managerdialoglayout_.build (Context,ad));

Call Setview (layout) before calling the Show method, and then call Window.setcontentview (layout) After show, and the two layout layouts should be the same.

As for the reason, temporarily unclear, but did solve the problem, click on the EditText, you can bring up the soft keyboard, input method.

January 6, 2013: The first method of the bug, the workaround:
Use a custom style:

<style name="Customdialogstyle"Parent="@Android: Style/theme.dialog"><item name="Android:windowframe"> @null </item><item name="android:windowisfloating">true</item><item name="android:windowistranslucent">true</item><item name="Android:windownotitle">true</item><item name="Android:background"> @android: Color/transparent</item><item name="Android:windowbackground"> @android: Color/transparent</item><item name="android:backgrounddimenabled">true</item><item name="Android:backgrounddimamount">0.6</item></style>Dialog AD=NewDialog (Context,r.style.customdialogstyle);

Android Development solves the problem that edittext in Alertdialog cannot recall input method

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.