警报对话框不显示单选按钮

Alert Dialog doesn't show radio buttons

我有一个 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();

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

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

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();