I will record the common methods of Dialog here, so that you can refer to them when you use them.
- Dialog constructor: you can define the theme style of the dialog box (the style is defined in styles.xml), such as whether there is a title, whether it is semi-transparent, and what is the background of the dialog box.
- getWindow: Get the window object of the dialog box. This method is the key to a custom dialog box. First, get the window object where the dialog box is located, and then add a custom view to this window.
- show: Show the dialog box.
- isShowing: Determine whether the dialog box is displayed.
- hide: Hide the dialog box.
- dismiss: Close the dialog box.
- setCancelable: Set whether the dialog box can be cancelled.
- setCanceledOnTouchOutSide: Click on the outer area of the dialog box to automatically close the dialog box. It will be turned off automatically by default.
- setOnShowListener: Set the display listener of the dialog box. Need to implement the onShow method of the OnShowListener interface.
- setOnDismissListener: Set the disappear listener of the dialog box. Need to implement the onDismiss method of the OnDismissListener interface.