相关疑难解决方法(0)

AlertDialog:为什么我不能一起显示消息和列表?

AlertDialog当我添加消息时,有人知道为什么不显示项目列表.setMessage()吗?将显示负面和正面按钮,但不会显示列表.当我删除所有行的行.setMessage().

这是我的代码:

AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this.getActivity());
myAlertDialog.setTitle("Options");
myAlertDialog.setMessage("Choose a color.");

CharSequence[] items = {"RED", "BLUE", "GREEN" };

myAlertDialog.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int which) {
        // do stuff
    }
});

myAlertDialog.setNegativeButton("NO",new DialogInterface.OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int which) {
       // do stuff
    }
});

myAlertDialog.setPositiveButton("YES",new DialogInterface.OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int which) {
       // do stuff
    }
});

myAlertDialog.create();
myAlertDialog.show();
Run Code Online (Sandbox Code Playgroud)

android android-alertdialog

20
推荐指数
3
解决办法
5243
查看次数

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

你能解释一下为什么这个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在哪里?

多谢你们.

android dialog android-alertdialog

0
推荐指数
1
解决办法
240
查看次数

标签 统计

android ×2

android-alertdialog ×2

dialog ×1