0

当我将日期选择器添加到我的活动时。它被正确添加。它的日期和月份部分是正确的,但是,年份部分显示的是日历。我也收到此错误-

The following classes could not be found:
- CalendarView (Change to android.widget.CalendarView, Fix Build Path, Edit XML)
- DatePicker (Change to android.widget.DatePicker, Fix Build Path, Edit XML) 

这是日期选择器代码 -

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >


<DatePicker
    android:id="@+id/datePicker1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true" />

这是我得到的输出(请忽略音量图像)。

这是我得到的输出

我想将它添加到我的应用程序中,以便我可以输入用户的出生日期。但由于年份部分(日历),它看起来不太好。

可能是什么问题?请帮忙。

4

1 回答 1

1

CalendarView是在 API 11 中添加的,因此您不能在 API 8 的最低 SDK 中使用它。

DatePicker 自 API 1 以来一直存在,因此要么是 CalendarView 错误正在创建这个错误,要么是您的 XML 中存在其他错误。但是除非您发布它,否则我无法知道确切的问题...


另外
,我不记得以前在哪里看到过这个确切的错误,但现在我知道它来自哪里: 截屏
这不会影响您的应用程序。该错误仅意味着 Eclipse 无法在您的布局中构建 DatePicker 或 CalendarView 的预览。该应用程序将运行良好(在 API 11+ 设备上)。

于 2013-02-04T20:43:20.100 回答