Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AlertDialog's items not displayed

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.

like image 573
Allan Mermod Avatar asked May 23 '12 06:05

Allan Mermod


People also ask

How to show dialog?

setTitle(CharSequence title)AlertDialog alertDialog = alertDialogBuilder. create(); alertDialog. show(); This will create the alert dialog and will show it on the screen.

What is a dialog box in android?

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.

What is Alert dialog in android?

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.


1 Answers

Use setTitle instead of setMessage which sets message body and overrides the items list.

like image 83
Paweł Nadolski Avatar answered Sep 19 '22 13:09

Paweł Nadolski