I create an AlertDialog
with an AlertDialog.Builder
and set some items with setItems()
. The dialog is shown but I cannot see any of the items. All I see is the message.
final CharSequence[] items = {"Red", "Green", "Blue"}; AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity); dialogBuilder.setMessage("Pick a color"); dialogBuilder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Do anything you want here } }); dialogBuilder.create().show();
If I set the PositiveButton
, I can see that button just fine. I also tried setting MultiChoiceItems
and SingleChoiceItems
but neither of these work either.
setTitle(CharSequence title)AlertDialog alertDialog = alertDialogBuilder. create(); alertDialog. show(); This will create the alert dialog and will show it on the screen.
A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed.
Android AlertDialog can be used to display the dialog message with OK and Cancel buttons. It can be used to interrupt and ask the user about his/her choice to continue or discontinue. Android AlertDialog is composed of three regions: title, content area and action buttons.
Use setTitle
instead of setMessage
which sets message body and overrides the items list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With