android - alertDialogTheme 不工作(AppCompat v23)

标签 android android-alertdialog android-appcompat android-theme

我的主题是这样的:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primaryDark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="alertDialogTheme">@style/AppTheme.Dialog</item>
</style>

<style name="AppTheme.Dialog" parent="Theme.AppCompat.Dialog.Alert">
    <item name="colorAccent">@color/accent</item>
</style>

但是,当我在我的应用程序中创建 AlertDialogs 时,它们根本没有主题。 ActionBar 等其他组件的颜色正确。我错过了什么吗?

我使用的是 AppCompat 版本 com.android.support:appcompat-v7:23.1.1 并且我的设备安装了 Android 4.4.4。

最佳答案

对于遇到类似问题的任何人:请仔细检查您是否使用支持库包中的 AlertDialog.Builder,因此导入语句应如下所示:

import android.support.v7.app.AlertDialog;

在我的例子中,我导入了导致错误结果的 android.app.AlertDialog

关于android - alertDialogTheme 不工作(AppCompat v23),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35682672/

相关文章:

android - 无法实例化类 android.support.v7.widget.SearchView

android - mipsel-linux-gcc : Command not found

android - 带有 ListView : two dividers between list item and button 的 AlertDialog

android - 如何从 DialogFragment 读取/写入首选项?

java - 以编程方式访问 AlertDialog PositiveButton

android - 更新到 androidx.appcompat :appcompat:1. 1.0 后的语言更改问题

android - 无法解析 : com. android.support :appcompat-v7:27. 0.3

Android - 仅在父 View 上播放动画

java - 通过 Fragment 显示 Activity 时出错

java - 错误 : Unable to run mksdcard SDK tool