Sometimes you want to show your users a dialog that contains more than just text and buttons. In those cases the pre-defined AlertDialog that come with Android will need some adjustment. Read here how to do that.

First of all we need an Alert Dialog Builder as always when it comes to creating dialogs in Android. If you want to go with backwards compatibility you should use the one that can be found inside the Android.Support.V7.App class, but you don’t necessarily need to. Instead of simply adding a title and a message we now have the chance to inflate our custom layout and set it as the dialog’s view.

Once the view is attached to the dialog we can manipulate it. We can access its elements by calling FindViewById from the dialogView.

Of course you can still attach buttons and event hanlders to your dialog or set a title, like you are used to it when working with the pre-definded alert dialog.

Don’t forget to show the dialog with builder.Show() and proudly present your first custom dialog to your users!

Robin-Manuel Thiel

At daylight, Robin-Manuel talks about new IT trends and development. But at night he turns into a tinker and developer which sometimes leads to insufficient sleep. He loves cool technologies, cross-platform and everything with a power-plug or IP address.


Dwight Ross · July 18, 2016 at 06:18

The buttons work fine but not the Edittext, I cannot set or get their value, I have been trying for almost an entire day.

Dwight Ross · July 18, 2016 at 06:34

Update: I got it (Editext=customView.FindViewById(Resource.Id.someview);)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.