Class AlertDialog.Builder<B extends AlertDialog.Builder<B>>

Type Parameters:
B - the type of the Builder that is returned
All Implemented Interfaces:
Accessible.Builder<B>, BuilderInterface
Enclosing class:
AlertDialog

public static class AlertDialog.Builder<B extends AlertDialog.Builder<B>> extends Dialog.Builder<B> implements Accessible.Builder<B>
Inner class implementing a builder pattern to construct a GObject with properties.
Since:
1.5
  • Constructor Details

    • Builder

      protected Builder()
      Default constructor for a Builder object.
  • Method Details

    • build

      public AlertDialog build()
      Finish building the AlertDialog object. This will call GObject.withProperties(Type, String[], Value[]) to create a new GObject instance, which is then cast to AlertDialog.
      Overrides:
      build in class Dialog.Builder<B extends AlertDialog.Builder<B>>
      Returns:
      a new instance of AlertDialog with the properties that were set in the Builder object.
    • setBody

      public B setBody(String body)
      The body text of the dialog.
      Parameters:
      body - the value for the body property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.5
    • setBodyUseMarkup

      public B setBodyUseMarkup(boolean bodyUseMarkup)

      Whether the body text includes Pango markup.

      See Pango#parseMarkup.

      Parameters:
      bodyUseMarkup - the value for the body-use-markup property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.5
    • setCloseResponse

      public B setCloseResponse(String closeResponse)

      The ID of the close response.

      It will be passed to AlertDialog::response if the dialog is closed by pressing Escape or with a system action.

      It doesn't have to correspond to any of the responses in the dialog.

      The default close response is close.

      Parameters:
      closeResponse - the value for the close-response property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.5
    • setDefaultResponse

      public B setDefaultResponse(String defaultResponse)

      The response ID of the default response.

      The button corresponding to this response will be set as the default widget of the dialog.

      If not set, the default widget will not be set, and the last added response will be focused by default.

      See Dialog:default-widget.

      Parameters:
      defaultResponse - the value for the default-response property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.5
    • setExtraChild

      public B setExtraChild(Widget extraChild)

      The child widget.

      Displayed below the heading and body.

      Parameters:
      extraChild - the value for the extra-child property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.5
    • setHeading

      public B setHeading(String heading)
      The heading of the dialog.
      Parameters:
      heading - the value for the heading property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.5
    • setHeadingUseMarkup

      public B setHeadingUseMarkup(boolean headingUseMarkup)

      Whether the heading includes Pango markup.

      See Pango#parseMarkup.

      Parameters:
      headingUseMarkup - the value for the heading-use-markup property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.5
    • setPreferWideLayout

      public B setPreferWideLayout(boolean preferWideLayout)

      Whether to prefer horizontal button layout.

      AdwAlertDialog can present buttons horizontally or vertically depending on available space, how many buttons there are and how wide they are.

      By default it will prefer to stack buttons vertically at medium sizes.

      Set to TRUE to prefer horizontal layout in these cases instead. This will make the dialog slightly wider as well.

      Vertical layout may still be used if the dialog would get too wide otherwise.

      Does nothing with just one button, or when the buttons are already horizontal.

      Parameters:
      preferWideLayout - the value for the prefer-wide-layout property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.6
    • onResponse

      public B onResponse(@Nullable String detail, AlertDialog.ResponseCallback handler)

      This signal is emitted when the dialog is closed.

      response will be set to the response ID of the button that had been activated.

      if the dialog was closed by pressing Escape or with a system action, response will be set to the value of AlertDialog:close-response.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.5
      See Also: