0

When I am adding date picker to my activity. It is added properly. Its date and month part are proper, but, the year part is showing the calendar. I am also getting this error -

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

here is the date picker code -

<RelativeLayout 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"
tools:context=".MainActivity" >


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

This th the output I am getting(Please ignore volume image).

This is the output I am getting

I want to add it to my app so that I can take input the date of birth from the user. But because of the year part (calendar) it is not looking good.

What can be the problem?Please help.

Ajay Sainy
  • 279
  • 1
  • 9
  • 21

1 Answers1

1

CalendarView was added in API 11, so you cannot use it with a minimum SDK of API 8.

DatePicker has been around since API 1, so either the CalendarView error is creating this one or there is something else wrong in your XML. But I have no way of knowing the exact problem unless you post it...


Addition
I couldn't remember where I had seen that exact error before, but now I know where it is coming from: screenshot
This won't affect your app. The error simply means Eclipse cannot build a preview of DatePicker or CalendarView in your layout. The app will run fine (on an API 11+ device).

Sam
  • 86,580
  • 20
  • 181
  • 179
  • what should i post...complete xml or complete java code...I have only one xml file and one java file. – Ajay Sainy Feb 06 '13 at 14:14
  • When I am running the app I am getting the DatePicker. and it is showing day and month part perfectly, but in place of year part it showing calendar, though I am able to select the year from that, but I want year part same as day and month part. – Ajay Sainy Feb 07 '13 at 14:31
  • The second answer [in this question](http://stackoverflow.com/q/12560495/1267661) will hide the CalendarView and should show the year just like the month and day. – Sam Feb 07 '13 at 16:27