2012-07-06 57 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