设置的Andr​​oid Theme.Light的警告对话框 [英] Set Android Theme.Light for Alert Dialog

查看:209
本文介绍了设置的Andr​​oid Theme.Light的警告对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置的android Theme.Light 主题我的提醒对话框,但没有成功为止。阅读一些教程后,我收集,使用 AlertDialog.Builder 我们不能在构造函数(ATLEAST在API 7级)直接设置的主题。

I am trying to set the android Theme.Light theme for my alert dialog, but with no success so far. After reading a few tutorials I gathered that using AlertDialog.Builder we cannot set the theme directly in the constructor (atleast in API level 7).

这是我发现的另一种解决方案是使用 ContextThemeWrapper ,其中每个人都保证会解决我的问题。所以我codeD是这样的:

The alternate solution that I found is using a ContextThemeWrapper, which everyone assured would solve my problem. So I coded something like this:

AlertDialog.Builder builder = new AlertDialog.Builder(
                    new ContextThemeWrapper(context, R.style.popup_theme));

我描述了我的主题,在价值观的文件夹:

I described my theme in the values folder:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="back_color">#ffffffff</color>
<style name="popup_theme" parent="@android:style/Theme.Light">
    <item name="android:windowBackground">@color/back_color</item>
    <item name="android:colorBackground">@color/back_color</item>
</style>

不幸的是我仍然得到默认的 Theme.Dialog.Alert 的主题。谁能告诉我为什么吗?我在哪里去了?

Unfortunately I still get the default Theme.Dialog.Alert theme. Can anyone tell me why? Where am I going wrong?

修改: 如果你不知道这个回答我的问题,请投了。我有张贴这卡住问题的一个坏习惯:(

EDIT: If you do not know the answer to my question, please vote up. I have a bad habit of posting questions which get stuck :(

推荐答案

变更父=机器人:Theme.Light父= @android:款式/ Theme.Light

这篇关于设置的Andr​​oid Theme.Light的警告对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆