As far as I know using AlertDialog.Builder
You can put up to 3 buttons...
button "POSITIVE" (setPositiveButton), neutral button (setNeutralButton), and "NEGATIVE" (setNegativeButton), but if you want more things like a Checkbox or a progress bar use the object Dialog
Example of a custom dialog:
public void showDialog() {
final Dialog dialog = new Dialog(MainActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(androidialog.graphics.Color.TRANSPARENT));
dialog.setContentView(R.layout.layout_dialog); // seu layout
dialog.setCancelable(false);
Button cancelar = (Button) dialog.findViewById(R.idialog.cancelar);
Button ok = (Button) dialog.findViewById(R.idialog.ok);
cancelar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss(); // fecha o dialog
}
});
ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss(); // fecha o dialog
}
});
dialog.show();
}
How so put another button? Explain better what you want to do with this code.
– user28595
@Diegofelipe already has a button that is
mensagem.setNeutralButton("OK", null);
would like to create one more that will execute a command.– Vale