CallMeDeftsu4
CallMeDeftsu4

Reputation: 127

Android - Alert dialog doesn't show items

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.

Upvotes: 0

Views: 480

Answers (2)

Ajaydharan Mohandoss
Ajaydharan Mohandoss

Reputation: 46

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

Upvotes: 1

Master Disaster
Master Disaster

Reputation: 759

setMessage overrides setItem so you have to remove setMessage.

Upvotes: 7

Related Questions