Alertdialog and custom dialog commonly used in Android

Common dialog boxes include confirmation dialog box, radio button dialog box, multi-choice button dialog box, check button dialog box, and user-defined dialog box

Common methods of alertdialog

Settitle: sets the title for the dialog box

SetMessage: set content for dialog box

Seticon: sets the icon for the dialog box

Set items sets the list to display in the dialog box

Setmultichoiceitems: generally used for check box display

Setsinglechoiceitem:, set radio button

Setneutralbutton: normal button

Setpositivebutton: add OK button

Setnegativebutton: add cancel button

Setview: set custom style

The following is an example to understand these methods

This is the result of the run:

MainActivity.class

Layout file

activity_ main.xml

Custom dialog layout file

item.xml

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. At the same time, I also hope to support a lot of programming tips!

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
分享
二维码
< <上一篇
下一篇>>