Implementing Popup UI Components in Android

Toast

Toast is a transient notification component for displaying brief messages.

  • Control the display position.
  • Customize the content, such as adding an image.
  • Create a utility class for reuse.

Common files: ToastActivity, activity_toast.xml, ToastUtil.

AlertDialog

An AlertDialog presents a modal window for user decisions.

  • Standard dialog with buttons.
  • Single-choice list dialog.
  • Multiple-choice list dialog.
  • Fully customized diallog layout.

Common files: DialogActivity, activity_dialog.xml, layout_dialog.xml.

ProgressBar and ProgressDialog

Use ProgressBar for indeterminate or determinate progress indication. ProgressDialog is deprecated; use ProgressBar within a Dialog or layout instead.

Example ProgressBar in XML:

<ProgressBar
    android:id="@+id/progressIndicator"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    style="@android:style/Widget.ProgressBar"
    android:indeterminateDrawable="@drawable/progress_background"
    android:layout_marginTop="10dp"/>

You can also define a custom style:

<ProgressBar
    android:id="@+id/progressIndicator"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    style="@style/CustomProgressBar"
    android:layout_marginTop="10dp"/>

Common files: ProgressActivity, activity_progress.xml.

Custom Dialog

Build a Dialog with a completely custom layout and behavior.

Common files: CustomDialog, CustomDialogActivity, bg_custom_dialog.xml, activity_custom.xml, layout_custom_dialog.xml.

PopupWindow

A PopupWindow displays a floating view anchored to another view, offering more layout flexibility than a Dialog.

Common files: PopupWindowActivity, activity_popup_window.xml, layout_popup.xml.

Tags: Android UI Components Toast AlertDialog ProgressBar

Posted on Wed, 13 May 2026 00:28:02 +0000 by floppy