【问题标题】:Alert Dialog doesn't show radio buttons警报对话框不显示单选按钮
【发布时间】:2021-09-12 11:08:42
【问题描述】:

我有一个alertDialog,代码如下:

AlertDialog.Builder b = new AlertDialog.Builder(Activity.this);
String[] types = getResources().getStringArray(R.array.text_spinner_NewClass_dayList);
b.setSingleChoiceItems(types, 2, (dialog, which) -> {
            textView.setText(types[which]);
            dialog.dismiss();
        }
);
b.show();

我想显示项目的所有单选按钮,但它只显示选定的项目。

【问题讨论】:

    标签: android android-alertdialog android-dialog android-radiobutton


    【解决方案1】:

    根据需要创建 xml 布局。并通过 View 扩展该布局以提醒对话框。

    AlertDialog.Builder b = new AlertDialog.Builder(Activity.this);
    
    //Your customized layout
    final View customLayout = getLayoutInflater().inflate(R.layout.custom, null);
    
    b.setView(customLayout);
    
    b.show();
    

    【讨论】:

    • 我知道,但它必须显示,因为在相同的代码中它显示所有单选按钮
    • 尝试更改警报对话框的主题颜色。可能是非活动单选按钮是白色的。
    • 是的,你是对的,当我改变主题颜色时,所有的单选按钮都会显示出来。谢谢
    猜你喜欢
    • 2019-03-05
    • 1970-01-01
    • 2020-04-12
    • 1970-01-01
    • 2020-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-08
    相关资源
    最近更新 更多