2012-10-17 22 views
11

Possible Duplicate:
Android CalendarView class cannot be found的DatePicker不工作時,試圖用它

我試圖把一個日期選取器在我的佈局,但替代的DatePicker那隻能說明:DatePicker

與此錯誤: The following classes could not be found: - DatePicker (Change to android.widget.DatePicker, Fix Build Path, Edit XML)我不知道這是什麼,因爲我已經在我的應用程序中有一個DatePicker,它工作正常,只是不知道爲什麼這個現在不工作。

<LinearLayout 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" 
    android:orientation="vertical" 
    tools:ignore="HardcodedText" > 

    <TextView 
     android:id="@+id/tvNomeR" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="" /> 

    <TextView 
     android:id="@+id/tvDataR" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="" /> 

    <TextView 
     android:id="@+id/textView3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="" /> 

    <TextView 
     android:id="@+id/tvMensagemR" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="" /> 

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <Button 
      android:id="@+id/bAdiarR" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Adiar" /> 

     <Button 
      android:id="@+id/bResponderR" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Responder" /> 

    </LinearLayout > 

</LinearLayout> 
+0

沒有向我們展示相關的代碼,幾乎不可能知道你做錯了什麼。 – Sam

+0

您可能缺少「import」語句 –

+0

問題陳述尚不清楚。請放一些代碼。究竟你在哪裏收到這個錯誤? –

回答

25

我在圖形佈局中看到你在說什麼,但這不會影響你的應用程序。這個錯誤僅僅意味着Eclipse無法爲您的佈局構建DatePicker的預覽。我敢打賭,如果你運行你的應用程序,它會顯示得很好。

screenshot

+0

它的確如此,謝謝。 –

+0

它適用於運行應用程序,但Android Studio中的可視化編輯器崩潰並且不允許您修改視圖。 –

13

(如this similar question回答)

您應該更改API Eclipse使用以圖形方式顯示您的佈局。您可以在右上方的圖形視圖中使用具有Android徽標的按鈕執行此操作。 API 16可能會帶來一些問題,所以請嘗試切換到15或14。 (需要一些時間來加載和刷新)

+1

我已經試過了,沒有結果:/ –

+0

它對我有用。你試過哪個API?你從eclipse檢查更新嗎? – Niels

+0

我通常建立他們在API 8(2.2 Froyo),我檢查4.0和新的Eclipse更新我得到了4.1試試,但很好,只有在xml設計不工作在運行應用程序是正常的:D –