0

嗨,我首先使用目标 api 3.0 开发了项目。当时它显示数字选择器如下

在此处输入图像描述

现在我用 15(4.0.3) 更改了目标和最低版本。它仍然显示旧的数字选择器。

我想看看下面的选择器。

在此处输入图像描述

4

2 回答 2

2

The problem can be resolved in one of several ways,

1 If you want to change the look and feel of all the date/time pickers in your app, you could apply a proper theme to the application

From Android 3.0 and afterwards app could use one of the following themes:

  • android:Theme series: the traditional (legacy) Android themes
  • android:Theme.Holo series: new Holo themes introduced since Android 3.0, the themes are created by Android and no one else shall modify it. Meaning that using the themes can keep your apps look and feel across devices.
  • android:Theme.DeviceDefault series: they are based on the Holo themes, but could b customized by every device manufacturer. Using the themes can make your app have similar look and feel as the built-in apps.

Applying one of the last two themes to your app could resolve your problem:

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/android:Theme.DeviceDefault" >

2 If you have no android:theme set for your app, then be aware of that the uses-sdk tag could decide the actual theme in use

See http://android-developers.blogspot.com/2012/01/holo-everywhere.html

So setting android:targetSdkVersion to a number equals or greater than 11 can resolve your problem.

3 If you are using a picker dialog and just want to change the look & feel of the single picker, then you could set a theme to the dialog only.

Like this:

Dialog dialog = new DatePickerDialog(this, AlertDialog.THEME_DEVICE_DEFAULT_DARK, new OnDateSetListener()...);

Note that AlertDialog.THEME_DEVICE_DEFAULT_DARK an API Level 14 API, you may also choose Holo themes like AlertDialog.THEME_HOLO_DARK which is available in API Level 11.

于 2013-01-25T07:16:53.867 回答
0

Just need to change theme to holo in manifiest file.

于 2013-01-25T07:15:53.753 回答