Android - 警报对话框不显示项目

Android - Alert dialog doesn't show 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>

错误在哪里?

谢谢大家。

setMessage 覆盖 setItem,因此您必须删除 setMessage。

参考here 由于上述原因未显示警告对话框项目。