2013-02-04 44 views
0

當我將日期選擇器添加到我的活動中時。它被正確添加。它的日期和月份部分是正確的,但是,年份部分正在顯示日曆。我也收到此錯誤 -Android中的日期選擇器看起來不太好

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" /> 

這屆我收到輸出(請忽略體積圖像)。

This is the output I am getting

我想將它添加到我的應用程序,這樣我可以輸入出生的來自用戶的日期。但由於年份(日曆),它看起來不太好。

可能是什麼問題?請幫忙。

+0

發佈您的整個XML佈局。什麼是您的最低SDK? – Sam

+0

@Sam - API 8 Android 2.2 –

+0

[This question and answer](http://stackoverflow.com/q/11365959/1267661)可能會有所幫助。 – Sam

回答

1

CalendarView在API 11中添加,所以你不能用API 8

的DatePicker已自API 1的最低SDK使用它,因此無論是CalendarView錯誤是創建這個還是有別的東西在您的XML錯誤。不過,我也沒有辦法知道確切的問題,除非你張貼的...


加成
我不記得我以前確切錯誤看到,但現在我知道在哪裏它來自: screenshot
這不會影響你的應用程序。錯誤只是意味着Eclipse無法在佈局中構建DatePicker或CalendarView的預覽。該應用可以正常運行(在API 11+設備上)。

+0

我應該發佈什麼......完整的xml或完整的java代碼......我只有一個xml文件和一個java文件。 –

+0

我更新了我的答案。 – Sam

+0

當我運行應用程序時,我得到DatePicker。並且它完美地顯示了日期和月份部分,但是代替年份顯示日曆,雖然我可以從中選擇年份,但我希望年份部分與日期和月份部分相同。 –

相關問題