IDialogpublic class ToastDialog extends CommonDialog
The toast dialog box is not clickable and it disappears automatically.
BaseDialog.DialogListener, BaseDialog.DisplayCallback, BaseDialog.RemoveCallbackCommonDialog.DestroyedListenerIDialog.CheckBoxClickedListener, IDialog.ClickedListener, IDialog.ItemClickedListener, IDialog.KeyboardCallbackBUTTON_NUM, BUTTON1, BUTTON2, BUTTON3, DEF_RADIUS, ICON_NUM, ICON1, ICON2, ICON3| 构造器 | 说明 |
|---|---|
ToastDialog(Context context) |
A constructor used to create a
ToastDialog instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
cancel() |
Cancels the current
ToastDialog. |
void |
destroy() |
Destroys an existing dialog box.
|
Component |
getComponent() |
Obtains the content of the dialog.
|
void |
hide() |
Hides the content of a dialog box.
|
protected void |
onCreate() |
Called from
BaseDialog to set the default layout. |
protected void |
onDestroy() |
Callback interface used when enabling automatic close of a
Dialog instance. |
protected void |
onShow() |
Enables a derived class to execute an operation when a toast dialog box is shown.
|
ToastDialog |
setAlignment(int gravity) |
Sets the dialog alignment mode.
|
ToastDialog |
setAutoClosable(boolean closable) |
Sets whether to enable automatic close of a
ToastDialog object. |
ToastDialog |
setComponent(Component component) |
Sets the customized component to use in the dialog.
|
ToastDialog |
setComponent(DirectionalLayout component) |
已过时。
This change is effective since API version 5. Replaced by
setComponent(Component) |
ToastDialog |
setDuration(int ms) |
Sets the duration for automatic close of a
ToastDialog object. |
ToastDialog |
setOffset(int offsetX,
int offsetY) |
Sets the display position offset for the dialog.
|
ToastDialog |
setSize(int width,
int height) |
Sets the size of a toast dialog.
|
ToastDialog |
setText(String textContent) |
Sets the text content in the dialog.
|
void |
show() |
Shows the
ToastDialog object. |
isShowing, obtainComponentViaId, onHide, onShowing, registerDisplayCallback, registerRemoveCallback, remove, searchComponentViaId, setCornerRadius, setDialogListener, setTransparentclickKeyDown, clickKeyUp, create, dealBackKeyDown, dealTouchEvent, deliverKeyboardCase, deliverTouchCase, getBoundRect, getButtonComponent, getContentCustomComponent, getWindow, isMovable, onWindowConfigUpdated, onWindowSelectionUpdated, setBoundRect, setButton, setContentCustomComponent, setContentImage, setContentText, setDestroyedListener, setImageButton, setMovable, setSwipeToDismiss, setTitleCustomComponent, setTitleIcon, setTitleSubText, setTitleText, siteKeyboardCallback, siteRemovablepublic ToastDialog(Context context)
ToastDialog instance.context - Indicates the ohos context obtained.public ToastDialog setText(String textContent)
It cannot be empty except in custom scenarios.
textContent - Indicates the text content in the dialog.ToastDialog object for further use. For example, obj.setText(text).show().@Deprecated public ToastDialog setComponent(DirectionalLayout component)
setComponent(Component) This is a ComponentContainer that encapsulates the customized component to be displayed.
component - Indicates the customized ComponentContainer.ToastDialog object for further use. For example, obj.setText(text).show().public ToastDialog setComponent(Component component)
This is a ComponentContainer that encapsulates the customized component to be displayed.
component - Indicates the customized ComponentContainer.ToastDialog object for further use. For example, obj.setText(text).show().public Component getComponent()
The obtained object is a ComponentContainer, which encapsulates the component to display.
public void cancel()
ToastDialog.
This dialog will not be destroyed but will not be displayed after execution.
public ToastDialog setAlignment(int gravity)
A toast dialog has many alignment modes, for example, bottom alignment.
setAlignment 在类中 BaseDialoggravity - Indicates the alignment mode to use.ToastDialog object for further use. For example, obj.setText(text).show().public ToastDialog setOffset(int offsetX, int offsetY)
This is the offset compared with the default alignment mode.
setOffset 在类中 BaseDialogoffsetX - Indicates the offset of the X axis.offsetY - Indicates the offset of the Y axis.ToastDialog object for further use. For example, obj.setText(text).show().public ToastDialog setSize(int width, int height)
setSize 在类中 BaseDialogwidth - Indicates the width to set.height - Indicates the height to set.ToastDialog instance for further use.public ToastDialog setAutoClosable(boolean closable)
ToastDialog object. This method is not supported for the
ToastDialog object.
If automatic close is enabled, a dialog automatically closes when touching or clicking a position outside the
ToastDialog object.
setAutoClosable 在类中 BaseDialogclosable - Indicates whether to enable automatic close of the ToastDialog object.ToastDialog object for continuous operations, for example,
obj.setAutoClosable(false).show().public ToastDialog setDuration(int ms)
ToastDialog object. This method is not supported for the
ToastDialog object.setDuration 在类中 BaseDialogms - Indicates the duration for automatic close of the ToastDialog instance.ToastDialog object for continuous operations, for example,
obj.setAutoClosable(false).show().public void show()
ToastDialog object.show 在接口中 IDialogshow 在类中 BaseDialogprotected void onCreate()
BaseDialog to set the default layout.onCreate 在类中 CommonDialogprotected void onShow()
onShow 在类中 CommonDialogpublic void destroy()
BaseDialogdestroy 在接口中 IDialogdestroy 在类中 BaseDialogpublic void hide()
BaseDialogA hidden dialog box is not destroyed.
hide 在接口中 IDialoghide 在类中 BaseDialogprotected void onDestroy()
BaseDialogDialog instance.
This callback is triggered only when the BaseDialog.destroy() method is invoked.
onDestroy 在类中 CommonDialog