The Android.App AlertDialog.Builder SetTitle is a method used to set the title of an alert dialog. This method is used to create a dialog box that alerts the user with a title and message. The package library for this method is Android.App.
Example 1:
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.SetTitle("Alert!"); alertDialogBuilder.SetMessage("This is an example alert dialog!"); alertDialogBuilder.SetPositiveButton("Okay", (senderAlert, args) => { Toast.MakeText(this, "Okay clicked!", ToastLength.Short).Show(); }); alertDialogBuilder.SetNegativeButton("Cancel", (senderAlert, args) => { Toast.MakeText(this, "Cancel clicked!", ToastLength.Short).Show(); });
Example 2:
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.SetIcon(Android.Resource.Drawable.IcDialogAlert); alertDialogBuilder.SetTitle("Confirm"); alertDialogBuilder.SetMessage("Do you want to delete this item?"); alertDialogBuilder.SetPositiveButton("Yes", (senderAlert, args) => { // Delete item code here }); alertDialogBuilder.SetNegativeButton("No", (senderAlert, args) => { // Do nothing });
In example 1, an alert dialog is created with a title, message, and two buttons: Okay and Cancel. When the user clicks either of the buttons, a Toast message is displayed.
In example 2, an alert dialog is created with an icon, title, message, and two buttons: Yes and No. When the user clicks the Yes button, the item is deleted. If the user clicks the No button, nothing happens.
C# (CSharp) Android.App AlertDialog.Builder.SetTitle - 30 examples found. These are the top rated real world C# (CSharp) examples of Android.App.AlertDialog.Builder.SetTitle extracted from open source projects. You can rate examples to help us improve the quality of examples.