Allan Mermod Allan Mermod - 1 year ago 84
Android Question

AlertDialog's items not displayed

I searched a lot but nothing found on my problem ...

I create an AlertDialog with AlertDialog.Builder and set some items with builder.setItems(). My dialog is shown as well but not my items ... I can see the dialog and his title but not my items.

Here's my code :

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


I tried to set PositiveButton and I can see it. I also tried to set MultiChoiceItems and SingleChoiceItems but nothing of these works ...

Do you have an idea ?

PS: Sorry if my english is bad...

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download