How to create custom popup

How a custom popup is created in android along with some actions(Buttons,input from user…) in that
which is prefered between AlertDialog and DialogFragment for that

Usually, you want your dialog to remain visible across configuration changes (screen rotate, locale change, entering/exiting split-screen mode, enabling/disabling Android 10’s dark mode, etc.). One way to do that is via DialogFragment.

With DialogFragment, you have your choice of supplying the whole Dialog (e.g., using AlertDialog) or just providing the core UI.

I have a chapter on dialogs in The Busy Coder’s Guide to Android Development.

I also want to know about Toast Popup and Message Popup

Sorry, but I do not know what “Message Popup” means.

To show a Toast, call Toast.makeText(context, ..., Toast.LENGTH_LONG).show(), where context is a Context (such as your Activity) and ... is a string or string resource ID. You can also use Toast.LENGTH_SHORT instead of Toast.LENGTH_LONG for a shorter-duration message.

I want to give Layout for the toast (Dialog as a Toast )

You would use something like:

Toast toast = new Toast();


where ... is your View. Personally, I do not recall ever using this approach.

Bear in mind that a Toast is non-interactive, so you will not be able to have input widgets (EditText, Button, etc.) that work.

1 Like

Is it possible to place Dialog where i want by providing (X,Y,width,height)

I have never done that, but apparently you can manipulate the LayoutParams for the window to do that.

It is not working, Is it Correct way or any other way

I have no idea. As I stated, I have never done this.