主题为Holo Light的DatePickerDialog?

Jul*_*lia 9 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);
Run Code Online (Sandbox Code Playgroud)

或主题android.R.style.Theme_Holo_Lightandroid.R.style.Theme_Holo_Light_Dialog,我得到一个标准标题和标准按钮的日期选择器.我也尝试使用自定义主题和holo light父级,但它也不起作用.它似乎与主题一起使用android.R.style.Theme_Holo,但结果是一个黑暗的背景(如预期的那样),但我希望有一个轻松的背景.

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

我在这里看到了一个例子:http://as400samplecode.blogspot.com/2011/10/android-datepickerdialog.html,它显示了一个DatePickerDialog带有holo light主题的方式,我希望拥有它.我不知道为什么它不适用于我的设置.

谢谢你的帮助.

Sup*_*abi 18

DatePickerDialog有它接受一个主题构造

DatePickerDialog(Context context, int theme, DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth)
Run Code Online (Sandbox Code Playgroud)

只需更新您的代码即可包含您想要的样式,而无需使用 ContextThemeWrapper

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

这样对我有用.