Android的CalendarView类不能被找到Android、CalendarView

2023-09-12 10:15:07 作者:志在四方

林设计在一个应用程序中使用的日历的XML格式,但我不能让日历在图形布局淋浴展现。

Im designing the xml format for a calendar to be used in an app, but I cant get the calendar to show in the graphical layout shower.

相反,我碰到下面的错误:

Instead I get the following 'error':

以下类不能被找到:    - CalendarView(更改为android.widget.CalendarView,修复构建路径,编辑XML)

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

在最小的SDK版本,这个项目是14和它的目标版本为15。

The min SDK version for this project is 14 and its target version is 15.

下面是我的 XML code:

Here is my XML code:

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

许多AP preciated!谢谢!

Much appreciated! Thanks!

推荐答案

你可能会对previewing屏幕上的Andr​​oid目标16.尝试使用Android的目标为15的布局图形编辑器(Android的图标上,在ADT 20 )。貌似有问题,Android的目标16。

you might be previewing your screen on Android Target 16. Try using Android Target 15 for Graphic Layout Editor (android icon on the top, in ADT 20). Looks like there is issue with Android Target 16.

请注意:您不要需要设置项目的目标只是目标图形布局编辑器

NOTE: You don't need to set the project target just the target in the graphical layout editor.