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

Cal*_*su4 0 android dialog android-alertdialog

你能解释一下为什么这个Dialog不会显示项目吗?

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();
Run Code Online (Sandbox Code Playgroud)

R.array.topicChoices

<string-array name="topicChoices">
    <item>Topic non letti</item>
    <item>Risposte non lette</item>
</string-array>
Run Code Online (Sandbox Code Playgroud)

这个bug在哪里?

多谢你们.

Mas*_*ter 5

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