Notice dialog

Updated at: 2023-03-03 08:49

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

Single-line title

AUNoticeDialog dialog = new AUNoticeDialog(this, "Single-line Title",
    "The description should not exceed 3 rows,and no ending mark is needed at the end of the last sentence.",
    "OK", "Cancel", true);
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.

    3 rows
  • 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

public AUNoticeDialog(Context context, CharSequence title, CharSequence msg,
        String positiveString, String negativeString);

public AUNoticeDialog(Context context, CharSequence title, CharSequence msg,
        String positiveString, String negativeString, boolean isAutoCancel) ;

/**
 * Create AUNoticeDialog based on the Input parameters.
 *
 * @param context The context object.
 * @param title The title.
 * @param msg The message.
 * @param positiveString Confirm button text.
 * @param negativeString Cancel button text.
 * @param isAutoCancel Indicates whether to automatically cancel actions in the area outside the pop-up window.
 */
public AUNoticeDialog(Context context, CharSequence title, CharSequence msg, String positiveString, String negativeString, boolean isAutoCancel);

/**
 * Set the color of the Confirm button text.
 *
 * @ Param c The color value.
 */
public void setPositiveTextColor(ColorStateList c);

/**
 * Set the color of the Cancel button text.
 *
 * @ Param c The color value.
 */
public void setNegativeTextColor(ColorStateList c);

/**
 * Obtain the Cancel button.
 */
public Button getCancelBtn();

/**
 * Obtain the Confirm button.
 */
public Button getEnsureBtn();

/**
 * Obtain title TextView.
 */
public TextView getTitle();

/**
 * Obtain message TextView.
 */
public TextView getMsg();

/**
 * Set the Confirm button tapping listener.
 *
 * @param listener
 */
public void setPositiveListener(OnClickPositiveListener listener);

/**
 * Set the Cancel button tapping listener.
 *
 * @param listener
 */
public void setNegativeListener(OnClickNegativeListener listener);

/**
 * Obtain RelativeLayout at the outermost layer of the pop-up window.
 */
public RelativeLayout getDialogBg();

/** 
 * Start the dialog and display it on screen.
 */
public void show();

Sample code

//Without a title.
AUNoticeDialog dialog = new AUNoticeDialog(this, "",
            "The description should be within three lines, and punctuation should not be at the rightmost side of a single line.",
            "Confirm", "Cancel", true);
dialog.show();

//Without description.
AUNoticeDialog dialog = new AUNoticeDialog(this, "Single-line title",
            "",
            "Confirm", null, true);
dialog.show();
  • On this page (0)
  • Sample image
  • Basic rules
  • Dependency
  • API
  • Sample code
Feedback
phone Contact Us