android - 主题为 Holo Light 的 DatePickerDialog?

标签 android android-widget android-theme

如何获得带有 Holo Light 主题的 DatePickerDialog?

创建DatePickerDialog时如下:

 DatePickerDialog dpd = new DatePickerDialog(new ContextThemeWrapper(this,
                    android.R.style.Theme_Holo_Light_Dialog_NoActionBar), 
    new DateListener(v), mTime.year, mTime.month, mTime.monthDay);

或使用主题 android.R.style.Theme_Holo_Lightandroid.R.style.Theme_Holo_Light_Dialog,我得到一个带有标准标题和标准按钮的日期选择器。我也尝试将自定义主题与全息灯父项一起使用,但它也没有用。它似乎适用于主题 android.R.style.Theme_Holo,但结果是深色背景(正如预期的那样),但我想要浅色背景。

该应用程序的android.jar 版本为14,该应用程序运行在android 版本为3.2 的设备上。

我在这里看到了一个例子:http://as400samplecode.blogspot.com/2011/10/android-datepickerdialog.html ,它显示了一个带有全息灯主题的 DatePickerDialog,这是我想要的方式。我不知道为什么它不适用于我的设置。

谢谢你的帮助。

最佳答案

DatePickerDialog 有一个接受主题的构造函数

DatePickerDialog(Context context, int theme, DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth)

只需更新您的代码以包含您想要的样式,而无需 ContextThemeWrapper

DatePickerDialog dpd = new DatePickerDialog(this,
                android.R.style.Theme_Holo_Light_Dialog_NoActionBar, 
new DateListener(v), mTime.year, mTime.month, mTime.monthDay);

我就是这样工作的。

关于android - 主题为 Holo Light 的 DatePickerDialog?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9278780/

相关文章:

android列表指向位置

java - Android:如何单独绘制.svg文件元素?

当 isIndicator = True 时,Android RatingBar 作为按钮

android - 从属首选项在禁用时显示错误的颜色字体

android - FAB的颜色什么时候依赖colorAccent?

android - 使用可绘制对象针对 Android 1.6 - 4.0.3

android - RecyclerView 项目在 RecyclerView 中变得不可见,滚动时有多种项目类型

java - 从android简单上传到S3

java - 如何将值从主屏幕小部件传递到应用程序?

android - 如何检查 View 小部件的类型?