Android Custom Dialog

Source: Internet
Author: User

With Alertdialog.builder, you can also customize your own dialog. But if there is edittext in dialog, you will find that clicking on the EditText system may not eject the soft keyboard. This problem does not occur when you use the inherited dialog method. Custom Dialog Sample code:

public class mydialog extends dialog{    private context  The Context;   //oncreate () function is not called until the show () method is called.      @Override     protected void oncreate (bundle  Savedinstancestate)  {        // todo auto-generated  method stub        super.oncreate (savedInstanceState);         this.setcontentview (r.layout.mydialog_layout);         //set the width of the dilaog to screen width-40, highly adaptive, dialog automatically centered.         this.getwindow (). setlayout (Context.getresources (). Getdisplaymetrics (). widthpixels-40,        layoutparams.wrap_content);     }    public mydialog (Context context)  {      &nbsP;  super (context);         // todo auto-generated  constructor stub        this.context=context;         //Remove title bar          This.requestwindowfeature (Window.feature_no_title);             }


This article is from the "focus_000" blog, make sure to keep this source http://120806872.blog.51cto.com/8289253/1606205

Android Custom Dialog

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.