I am trying to use a DatePicker:
My code is:
DatePicker datePicker = (DatePicker) v.findViewById(R.id.dialog_date_datePicker);
datePicker.init(year, month, day, new OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker view, int year, int month,
int day) {
mDate = new GregorianCalendar(year, month, day).getTime();
getArguments().putSerializable(EXTRA_DATE, mDate);
}
});
But when I select a date the onDateChanged method is never called. After googling I found that if I changed my date picker layout to include: android:datePickerMode="spinner" /> and remove android:calendarViewShown="false" the onDateChanged is called and the code works but the date picker dialog is really bad looking.
My layout is:
<DatePicker xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog_date_datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:datePickerMode="spinner" />
<!-- android:calendarViewShown="false" -->
So why is the calenderViewShown attribute causing a problem and how can I improve the look of the date picker UI dialog?