Android dialog dialog details and sample code

Android dialog dialog

1. Dialog introduction

2. Basic use of alertdialog

3. Custom dialogcustom dialog

1、 Dialog introduction

Dialog is also a common user interface element in Android. Like menu, it is not a subclass of view. Let's take a look at its inheritance relationship:

Here, you should pay attention to its direct subclasses alertdialog and indirect subclasses DatePickerDialog, ProgressDialog and timepickerdialog. We have talked about the last three in the previous chapters. Today we will focus on alertdialog.

2、 Basic use of alertdialog

Alertdialog dialog is a subclass of dialog. It provides an icon, a title, a text and three buttons. In the activity, we can create and display dialog by ourselves, or manage it through the activity method. We can learn how to use it through the following example. Please also pay attention to the comments in the code.

1. Create a project lesson17_ Helloalertdialog, the file name of the activity is mainhelloalertdialog java

2、res/layout/main. The contents of XML are as follows:

3、MainHelloAlertDialog. The contents of Java are as follows:

4. The operation results are as follows:

Interested students can consider how to improve the close and remove dialog buttons.

The above is the sorting of Android dialog data. We will continue to supplement it later. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>