Ajay Sainy
Ajay Sainy

Reputation: 379

Date Picker in Android not looking good

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.

Upvotes: 0

Views: 4005

Answers (1)

Sam
Sam

Reputation: 86948

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

Upvotes: 1

Related Questions