AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetMessage("This is a simple alert dialog box."); builder.SetCancelable(false); builder.SetPositiveButton("OK", delegate { // do something when user clicks OK button }); AlertDialog alert = builder.Create(); alert.Show();
string[] options = {"Yes", "No", "Maybe"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Do you like this app?"); builder.SetItems(options, delegate (object sender, DialogClickEventArgs args) { // do something based on user selection switch (args.Which) { case 0: Toast.MakeText(this, "You selected Yes.", ToastLength.Short).Show(); break; case 1: Toast.MakeText(this, "You selected No.", ToastLength.Short).Show(); break; case 2: Toast.MakeText(this, "You selected Maybe.", ToastLength.Short).Show(); break; } }); builder.SetCancelable(false); builder.SetPositiveButton("Cancel", delegate { // do something when user clicks Cancel button }); AlertDialog alert = builder.Create(); alert.Show();This code creates a customized alert dialog box with a title and a set of options. When the user selects an option, a message is displayed based on the selection. The dialog box also has a cancel button. The above examples use the `Android.App` package library, which is part of the Android SDK for C#. This library provides a set of classes and interfaces for building Android applications using C#.