11

Possible Duplicate:
Android CalendarView class cannot be found

I tried putting a Date Picker in my layout but instead of the DatePicker it only shows: DatePicker

and this error: The following classes could not be found: - DatePicker (Change to android.widget.DatePicker, Fix Build Path, Edit XML) I don't know what this is because I already have a DatePicker in my app and it works fine just don't know why this one now isn't working.

<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>
Community
  • 1
  • 1
baTimá
  • 554
  • 1
  • 10
  • 28
  • Without showing us the relevant code, it is almost impossible to know what you are doing wrong. – Sam Oct 17 '12 at 20:11
  • you are probably missing an `import` statement – Ovidiu Latcu Oct 17 '12 at 20:11
  • Problem statement is unclear. Please put some code. Exactly where are you receiving this error? – Parag Meshram Oct 17 '12 at 20:11
  • Nothing i can say. I ain't doing nothing wrong, or is it clicking the DatePicker and moving to the layout wrong? – baTimá Oct 17 '12 at 20:13
  • @baTimá - try 1. Clean Build 2. Use ` – Parag Meshram Oct 17 '12 at 20:18
  • You need to include your Java file, and maybe a logcat output. You are obviously doing something wrong, but no-one can help you if you don't put more info. – Booger Oct 17 '12 at 20:19
  • @ParagMeshram None of them worked. – baTimá Oct 17 '12 at 20:21
  • @Booger as I said, NEW LAYOUT.XML file i just dragged the DatePicker to the layout and error cames, what possibly is wrong what my Java(which i dont have nothing in my java)s? When I run the App it shows normally, but i want to know why is it showing wrong in the .xml file? – baTimá Oct 17 '12 at 20:25
  • @baTimá - I am getting the same message in Eclipse's Graphical Layout view of Layout.xml but it is a `warning` and code compiles just fine. This warning is not visible in `Problems` pane. – Parag Meshram Oct 17 '12 at 20:30
  • Yes, oh well, gotta keep with the "error" then. thanks – baTimá Oct 17 '12 at 20:33

2 Answers2

25

I see what you are talking about in the Graphical Layout, but this won't affect your app. This error simply means Eclipse cannot build a preview of DatePicker for your layout. I bet if you run your app it will display just fine.

screenshot

Sam
  • 86,580
  • 20
  • 181
  • 179
  • It works if you run the app, but the Visual Editor in Android Studio crashes and does not allow you to modify the view. – Antonio Sesto Feb 16 '15 at 23:00
13

(As answered in this similar question)

You should change the api eclipse uses to graphically display your layout. You do this in the graphic view, in the top right, with the button that has the android logo. API 16 might give some problems, so try switching to 15 or 14 instead. (It will take a bit of time to load and refresh)

Community
  • 1
  • 1
Niels
  • 1,340
  • 2
  • 15
  • 32
  • 1
    i tried it already and no result :/ – baTimá Nov 28 '12 at 16:37
  • It worked for me. Which API did you try? Did you check for updates from eclipse? – Niels Nov 29 '12 at 08:25
  • i usually build them in API 8 (2.2 froyo) and i check in 4.0 and the new eclipse update i got the 4.1 to try but well, only in xml design doesnt work in running app is normal :D – baTimá Nov 29 '12 at 15:47
  • 4
    Yes, the 4.1(=API 16) in eclipse didn't show it for me either, but API 14(=4.0.2) did. Via the android SDK manager you can download additional API's so you can test it in those. – Niels Nov 30 '12 at 09:57