0

Can you explain me why this Dialog won't display items?

new AlertDialog.Builder(MainActivity.context)
                        .setTitle("Gestione topic")
                        .setMessage("Cosa vuoi leggere?")
                        .setItems(R.array.topicChoices, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                //code here
                            }
                        }).setNegativeButton("Annulla", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).show();

R.array.topicChoices

<string-array name="topicChoices">
    <item>Topic non letti</item>
    <item>Risposte non lette</item>
</string-array>

Where is the bug?

Thanks, guys.

CallMeDeftsu4
  • 127
  • 1
  • 12

2 Answers2

7

setMessage overrides setItem so you have to remove setMessage.

Master Disaster
  • 729
  • 4
  • 21
1

Refer here where the alert dialog items are not displayed due to the above reason.

Community
  • 1
  • 1