Use DialogX to quickly build Android App

Time:2022-11-16

Use DialogX to quickly build Android App dialog boxes

Traditional native dialog components existmemory leak, Insufficient customization, the development is often troubled by all kinds of strange crashes, facing products and designers such as “the rounded corners of the dialog box are larger”, “can you follow theiOSThe fuzzy effect of the design draft, “Sliding down the list interface to automatically close the dialog box” and many other requirements are difficult to solve, and you don’t want to encapsulate or write a lot of code every time to achieve a small prompt box requirement. can tryDialogX, it is enough to meet various dialog components such as quickly completing dialog boxes, blocking prompt boxes, non-blocking prompt boxes, bottom dialog boxes, etc. in most scenarios, and can perfectly meet the needs of various themes and function extensions. It greatly facilitates the development process and helps you quickly build application dialog functions.

Ease of use comparison

Compared with traditional AlertDialog, DialogX has great advantages:

  • DialogX adopts a new implementation method. The default View implementation method is lighter, and Window and DialogFragment implementation methods are also optional, free and flexible.
  • The startup of DialogX has nothing to do with the thread, you can start it in any threadDialogXAnd it will all run automatically on the UI thread.
  • DialogX starts withoutcontext parameter, by default, a static method is provided to start the dialog box with one line of code, which is more convenient to use.
  • More freedom, developers can easily customize the style of any component in the dialog box, including text style, button text style, menu text style, input text style, as large as the title, as small as the prompt message can be modified as needed.
  • DialogX adopts theme-separated design, comes with Material theme by default, and can optionally introduce other style themes such as IOS, Kongzue, MIUI, etc., which greatly reducesApp size, while providing a theme interface, if there is a need for customization, you can implement a set of private themes by yourself.
  • Less coupling, fewer problems,DialogXYou can close the Activity at will while the dialog box is running, without worrying about the WindowLeaked error that components such as AlertDialog used to cause.
  • For a smoother experience, the animation effects of DialogX are richer. The dialog box startup animation is realized by non-linear animation, and it also has a coherent transition effect from waiting for prompts to completing error animations, making your APP more dynamic.
  • All themes support two modes of bright and dark colors by default. You can switch between bright and dark dialog themes with just one-click configuration, and more free layout content to meet customized needs.DialogXIt also supports automatic adaptation to the switching of the system’s bright and dark color modes, and can automatically judge the switching of bright and dark color display effects according to the system settings.
  • Easily realize the lifecycle control and immersive adaptation of dialog boxes.

Simply put, generally we have to write aAlertDialog, to complete a simple confirmation prompt, at least the following code is required:

AlertDialog Demo

//Build AlertDialog Builder
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Title");
builder.setMessage("Here is the text content.");
builder.setCancelable(true); //Click on the area outside the dialog box to make the dialog box disappear
Builder. SetPositiveButton (" sure, "the new DialogInterface. An OnClickListener () {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        Toast.makeText(context, "You clicked yes", Toast.LENGTH_SHORT).show();
        dialog.dismiss();
    }

});
AlertDialog dialog = builder.create();
dialog.show(); //Display dialog box

MessageDialog Demo

MessageDialog.show("Title", "Here is the text content.", "OK");

Of course, you can also use it according to your own habitsbuild methodConstruct:

MessageDialog.build()
        .setTitle("Title")
        .setMessage("Here is the text content.")
        .setOkButton("OK")
        .show();

In terms of code size alone,DialogXIt is more convenient. Secondly, DialogX also has many unique advantages. You will feel that writing a desired dialog box will become very simple during the coding process.

DialogXalso supportnullInput, as long as you want, you can specify any element not to be displayed, set itnullThat’s it.

A wide variety of components to suit your needs

DialogXContains a variety of components, the message prompt box MessageDialog and the selection dialog based on it, the input dialog InputDialog, to meet the basic dialog scene requirements, the default is the Material theme style.

Use DialogX to quickly build Android App

Blocking prompt boxWaitDialog, and the prompt box TipDialog, which is suitable for scenes that require strong prompts and prevent users from continuing to operate the interface. When used in combination, these two components can be used in conjunction, that is, they can seamlessly transition from WaitDialog to TipDialog through animation when it is displayed. TipDialog defaults Include‘Done’, ‘Warning’, ‘Error’There are three states, WaitDialog contains two modes of circling and displaying progress by default:

Use DialogX to quickly build Android App

The bottom dialog box BottomDialog meets the needs of the pop-up dialog box at the bottom of the screen. The Material theme comes with a slide-down function, or you can directly use the bottom menu BottomMenu to quickly complete the user’s selection needs.

Use DialogX to quickly build Android App

Non-blocking prompt PopTip is similar to Toast. When the prompt is displayed, the user can continue to operate the interface, and can quickly set the display content, customize the display duration, customize the icon and operation button

Use DialogX to quickly build Android App

The full-screen dialog box FullScreenDialog can float a dialog interface layer on the current Activity, and the content displayed by the Activity will have a certain “sinking” animation effect, which is suitable for the operation requirements that require full-screen processing:

Use DialogX to quickly build Android App

In addition, DialogX also provides CustomDialog to meet complete customization needs. In CustomDialog, everything is implemented based on your own layout layout. You can also easily control the background mask, the position where your own layout needs to be displayed, and even bind it. Displayed around an Activity interface element to guide prompt requirements:

Use DialogX to quickly build Android App