AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("This is a message."); builder.show();
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Title"); builder.setMessage("This is a message."); builder.show();
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Title"); builder.setMessage("This is a message."); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Do something } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Do something } }); builder.show();This code creates a dialog box that displays a message with "OK" and "Cancel" buttons. It also sets actions for when the buttons are clicked. Overall, AlertDialog.Builder is a useful tool for displaying information and making requests to users on Android apps.