All Products
Search
Document Center

Notice dialog

Last Updated: May 25, 2021

AUNoticeDialog (formerly APNoticePopDialog) provides a dialog box containing a title, body, a Confirm button, and a Cancel button. It can be used to display common notices.

Sample image

 
  1. AUNoticeDialog dialog = new AUNoticeDialog(this, "标题单行",
  2. "描述文字的字数尽量控制在三行内,并且单行最右侧尽量不要是标点符号。",
  3. "确定", "取消", true);
  4. dialog.show();

Basic rules

  • A pop-up window has a minimum height.
  • When the window contains only a title or description, it is vertically centered and displayed at the minimum height.

  • The text of the Confirm and Cancel buttons should contain a maximum of four words. Otherwise, the text may not be fully displayed on a phone with a small screen (such as VIVO Y23L).

Dependency

See Quick start.

API

 
  1. public AUNoticeDialog(Context context, CharSequence title, CharSequence msg,
  2. String positiveString, String negativeString);
  3. public AUNoticeDialog(Context context, CharSequence title, CharSequence msg,
  4. String positiveString, String negativeString, boolean isAutoCancel) ;
  5. /**
  6. * Create AUNoticeDialog based on the Input parameters.
  7. *
  8. * @param context The context object.
  9. * @param title The title.
  10. * @param msg The message.
  11. * @param positiveString Confirm button text.
  12. * @param negativeString Cancel button text.
  13. * @param isAutoCancel Indicates whether to automatically cancel actions in the area outside the pop-up window.
  14. */
  15. public AUNoticeDialog(Context context, CharSequence title, CharSequence msg, String positiveString, String negativeString, boolean isAutoCancel);
  16. /**
  17. * Set the color of the Confirm button text.
  18. *
  19. * @ Param c The color value.
  20. */
  21. public void setPositiveTextColor(ColorStateList c);
  22. /**
  23. * Set the color of the Cancel button text.
  24. *
  25. * @ Param c The color value.
  26. */
  27. public void setNegativeTextColor(ColorStateList c);
  28. /**
  29. * Obtain the Cancel button.
  30. */
  31. public Button getCancelBtn();
  32. /**
  33. * Obtain the Confirm button.
  34. */
  35. public Button getEnsureBtn();
  36. /**
  37. * Obtain title TextView.
  38. */
  39. public TextView getTitle();
  40. /**
  41. * Obtain message TextView.
  42. */
  43. public TextView getMsg();
  44. /**
  45. * Set the Confirm button tapping listener.
  46. *
  47. * @param listener
  48. */
  49. public void setPositiveListener(OnClickPositiveListener listener);
  50. /**
  51. * Set the Cancel button tapping listener.
  52. *
  53. * @param listener
  54. */
  55. public void setNegativeListener(OnClickNegativeListener listener);
  56. /**
  57. * Obtain RelativeLayout at the outermost layer of the pop-up window.
  58. */
  59. public RelativeLayout getDialogBg();
  60. /**
  61. * Start the dialog and display it on screen.
  62. */
  63. public void show();

Sample code

 
  1. //Without a title.
  2. AUNoticeDialog dialog = new AUNoticeDialog(this, "",
  3. "The description should be within three lines, and punctuation should not be at the rightmost side of a single line.",
  4. "Confirm", "Cancel", true);
  5. dialog.show();
  6. //Without description.
  7. AUNoticeDialog dialog = new AUNoticeDialog(this, "Single-line title",
  8. "",
  9. "Confirm", null, true);
  10. dialog.show();