IDialogCommonDialog, DisplayDialog, PopupDialogpublic class BaseDialog extends Object implements IDialog
IDialog
This class implements basic function of the IDialog class.
It is inherited by its child classes to implement a specific dialog box.
IDialog| 限定符和类型 | 类 | 说明 |
|---|---|---|
static interface |
BaseDialog.DialogListener |
Represents the listener for events of a dialog box.
|
static interface |
BaseDialog.DisplayCallback |
Represents the callback that is invoked when a dialog box is displayed.
|
static interface |
BaseDialog.RemoveCallback |
Represents the callback that is invoked when a dialog box is removed.
|
IDialog.CheckBoxClickedListener, IDialog.ClickedListener, IDialog.ItemClickedListener, IDialog.KeyboardCallbackBUTTON_NUM, BUTTON1, BUTTON2, BUTTON3, DEF_RADIUS, ICON_NUM, ICON1, ICON2, ICON3| 构造器 | 说明 |
|---|---|
BaseDialog(Context context) |
Base class used to create a
Dialog instance. |
BaseDialog(Context context,
int flag) |
The constructor of BaseDialog for DisplayDialog.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
protected void |
create() |
Creates a
Dialog instance. |
void |
destroy() |
Destroys an existing dialog box.
|
void |
hide() |
Hides the content of a dialog box.
|
boolean |
isShowing() |
Checks if a
Dialog instance is showing. |
Component |
obtainComponentViaId(int id) |
Searches for the component with a specified ID.
|
protected void |
onCreate() |
Callback interfaced used when creating a
Dialog instance. |
protected void |
onDestroy() |
Callback interface used when enabling automatic close of a
Dialog instance. |
protected void |
onHide() |
Callback interface used when hiding a
Dialog instance. |
protected void |
onShow() |
Callback interface used when showing a
Dialog instance. |
protected void |
onShowing() |
Called when the pre-layout of a dialog box is complete
and the content is being shown in the dialog box.
|
void |
registerDisplayCallback(BaseDialog.DisplayCallback callback) |
Registers a callback that is invoked when a dialog box is displayed.
|
void |
registerRemoveCallback(BaseDialog.RemoveCallback callback) |
Registers a callback that is invoked when a dialog box is removed.
|
void |
remove() |
Removes a dialog box.
|
Component |
searchComponentViaId(int id) |
Searches for the component with a specified ID.
|
BaseDialog |
setAlignment(int alignment) |
Sets the alignment attribute of a
Dialog instance. |
BaseDialog |
setAutoClosable(boolean closable) |
Sets whether to enable automatic close a dialog box.
|
BaseDialog |
setCornerRadius(float radius) |
Sets the radius of the round corners of a dialog box.
|
void |
setDialogListener(BaseDialog.DialogListener listener) |
Sets the listener for events of a dialog box.
|
BaseDialog |
setDuration(int ms) |
Sets the duration for automatic close of a dialog box.
|
BaseDialog |
setOffset(int offsetX,
int offsetY) |
Sets the offset for a dialog box.
|
BaseDialog |
setSize(int width,
int height) |
Sets the size of a dialog box.
|
BaseDialog |
setTransparent(boolean isEnable) |
Sets whether to enable transparent background for a dialog box.
|
void |
show() |
Shows the content of a dialog box.
|
public BaseDialog(Context context)
Dialog instance.
When calling this method, you must obtain a valid Context object.
context - Indicates the context.public BaseDialog(Context context, int flag)
When calling this method, you must obtain a valid Context object.
context - Indicates the context.flag - Indicates the flag.WindowManager.PermissionException - Throws this exception if dialog context is invalid.public void show()
show 在接口中 IDialogWindowManager.PermissionException - Throws this exception if no dialog box is found.public void hide()
A hidden dialog box is not destroyed.
public boolean isShowing()
Dialog instance is showing.
The showing state of a dialog box remains unchanged even it is overlapped.
True if the Dialog instance is showing; returns False otherwise.public BaseDialog setTransparent(boolean isEnable)
isEnable - Indicates whether transparent background will be enabled.
True indicates is enabled; False indicates disabled.BaseDialog object for continuous operations,
for example, obj.setAutoClosable(false).show().public BaseDialog setCornerRadius(float radius)
radius - Indicates the radius of the round corners of the dialog box.BaseDialog object for continuous operations,
for example, obj.setAutoClosable(false).show().public BaseDialog setAutoClosable(boolean closable)
If automatic close is enabled, a dialog box automatically closes when touching or clicking a position outside the dialog box.
closable - Indicates whether to enable automatic close of the dialog box.BaseDialog object for continuous operations,
for example, obj.setAutoClosable(false).show().public BaseDialog setDuration(int ms)
ms - Indicates the duration for automatic close of the Dialog instance.BaseDialog object for continuous operations,
for example, obj.setAutoClosable(false).show().public BaseDialog setSize(int width, int height)
The default size is used If the user leaves the size unspecified.
width - Indicates the expected width of the dialog box.height - Indicates the expected height of the dialog box.BaseDialog object for continuous operations,
for example, obj.setAutoClosable(false).show().public BaseDialog setAlignment(int alignment)
Dialog instance.
By default, a dialog box is displayed at the center.
alignment - Indicates the expected position to display the dialog box.BaseDialog object for continuous operations,
for example, obj.setAutoClosable(false).show().public BaseDialog setOffset(int offsetX, int offsetY)
The offset can be set after the alignment attribute is set.
offsetX - Indicates the X-axis offset of the dialog box.offsetY - Indicates the Y-axis offset of the dialog box.BaseDialog object for continuous operations,
for example, obj.setAutoClosable(false).show().public void setDialogListener(BaseDialog.DialogListener listener)
listener - Indicates the listener for events of the dialog box.protected void create()
Dialog instance.
This method takes priority over the onShow() method.
protected void onCreate()
Dialog instance.
This method takes priority over the onShow() method.
protected void onShow()
Dialog instance.
This method takes priority over the onShowing() method.
protected void onHide()
Dialog instance.
This callback is triggered only when the hide() method is invoked
protected void onDestroy()
Dialog instance.
This callback is triggered only when the destroy() method is invoked.
protected void onShowing()
public void registerRemoveCallback(BaseDialog.RemoveCallback callback)
callback - Indicates the callback to register.public void remove()
When a dialog box is removed via this method, RemoveCallback is invoked.
This is how this method differs from destroy().
public void registerDisplayCallback(BaseDialog.DisplayCallback callback)
callback - Indicates the callback to register.public Component searchComponentViaId(int id)
id - Indicates the ID of the component to search for.null if id is invalid,
indicating that the component does not exist or no dialog box is available.public final Component obtainComponentViaId(int id)
This method is the same as searchComponentViaId(int Id),
except that an exception is thrown if the specified ID is invalid.
id - Indicates the ID of the component to search for.IllegalStateException - Throws this exception if id is invalid.