Android custom exit dialog box

Source: Internet
Author: User

Custom exit pop-up boxes are not very common in applications. We often see them in games. Next, let's take a look at how it is implemented. First, we define a method to call this method when the user clicks to exit.

 1     Private   Void  Dialog (){  2           Final Alertdialog DLG = New Alertdialog. Builder ( This  ). Create ();  3   DLG. Show ();  4 Window window = DLG. getwindow (); 5   Window. setcontentview (R. layout. Talk );  6 Button OK = (Button) window. findviewbyid (R. Id. btn_ OK );  7 OK. setonclicklistener ( New  View. onclicklistener (){  8               Public   Void  Onclick (view v ){  9 Main. This . Finish ();  10   }  11   });  12 Button cancel = (Button) window. findviewbyid (R. Id. btn_cancel );  13 Cancel. setonclicklistener ( New  View. onclicklistener (){  14        Public   Void  Onclick (view v ){ 15   DLG. Cancel ();  16   }  17   });  18 }

This is not much different from the normal pop-up box. You can use these two sentences to get the custom shape of the pop-up box.

 
Window window = DLG. getwindow (); window. setcontentview (R. layout. Talk );

For example:

So far, the design of the custom pop-up box has been completed.

 

 

 

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.