2012-07-06 75 views
29

我設計的日曆xml格式用於應用程序,但我不能讓日曆顯示在圖形佈局淋浴。Android CalendarView類無法找到

相反,我得到了下面的 '錯誤':

以下類找不到: - CalendarView(更改爲android.widget.CalendarView,修復構建路徑,編輯XML)

的最小SDK版本爲這個項目是14和它的目標的版本是15

這裏是我的XML代碼:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" > 

     <RelativeLayout android:id="@+id/top" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
       <Button android:id="@+id/dash" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:maxWidth="200dp" 
        android:maxHeight="10dp" 
        android:text="DASHBOARD" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:layout_alignParentLeft="true"/> 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerInParent="true" 
        android:paddingBottom="10px" 
        android:paddingTop="10px" 
        android:text="Calendar" 
        android:textAppearance="?android:attr/textAppearanceLarge"/> 
       <Button 
        android:id="@+id/plusButton" 
        style="?android:attr/buttonStyleSmall" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:text="+" 
        android:textAppearance="?android:attr/textAppearanceLarge"/> 
     </RelativeLayout> 
     <CalendarView 
      android:id="@+id/calview" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/top" 
      android:maxHeight="300dp" /> 

     <RelativeLayout android:id="@+id/infoScroll" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/calview"> 

      <ScrollView 
       android:id="@+id/scrollView1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:maxHeight="100dp"> 

       <ListView 
        android:id="@+id/listView1" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" > 
       </ListView> 

      </ScrollView> 
     </RelativeLayout> 
     <RelativeLayout android:id="@+id/bottomBar" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/infoScroll"> 
      <Button android:id="@+id/todayButton" 
       android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_alignParentLeft="true" 
        android:text="Today" 
       android:textAppearance="?android:attr/textAppearanceSmall"/> 

      <Button android:id="@+id/listButton" 
       android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_toLeftOf="@+id/dayButton" 
        android:text="List" 
        android:textAppearance="?android:attr/textAppearanceSmall"/> 

     <Button android:id="@+id/dayButton" 
       android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerInParent="true" 
        android:text="Day" 
       android:textAppearance="?android:attr/textAppearanceSmall"/> 

     <Button 
      android:id="@+id/monthButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@+id/dayButton" 
      android:text="Month" 
      android:textAppearance="?android:attr/textAppearanceSmall"/> 

     <Button android:id="@+id/PeopleButton" 
      android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
        android:layout_alignParentRight="true" 
       android:text="People" 
       android:textAppearance="?android:attr/textAppearanceSmall"/> 



     </RelativeLayout> 

</RelativeLayout> 

非常感謝!謝謝!

+0

標記爲答案,如果這解決了您的問題:) – 2013-07-05 13:54:11

回答

42

您可能正在Android Target 16上預覽屏幕。嘗試使用Android Target 15進行圖形佈局編輯器(頂部的Android圖標爲ADT 20)。看起來像是Android Target 16存在問題。

注意:您不需要需要在圖形佈局編輯器中將項目目標設置爲目標。

+1

您的答案讓我繼續相信,我不能使用DatePicker元素出於某種原因。我以爲「無法找到DatePicker類?」,然後我發現這篇文章。 DatePicker工作得很好。再次感謝。 – LargeGlasses 2014-06-18 18:39:10