AlertDialog 不显示带有 Material 组件主题的项目

And*_*Dev 1 android android-alertdialog material-design material-components material-components-android

如何在 AlertDialog.Only AlertDialog 中显示项目,没有任何项目我正在尝试下面的代码,但这似乎不起作用:

CharSequence[] choices = {"Choice1", "Choice2", "Choice3"};

AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context)
.setTitle(context.getString(R.string.title))
.setPositiveButton(context.getString(R.string.Ok), null)
                            .setNeutralButton(context.getString(R.string.Cancel), null)
.setSingleChoiceItems(choices, 1, null);

AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
Run Code Online (Sandbox Code Playgroud)

我正在使用材料组件样式:

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

Bil*_*ash 5

我面临同样的问题。然后在尝试了很多解决方案之后,我才知道 removesetMessage()在 MaterialAlertDialogBu​​ilder 中对我有用