Reputation: 179
I want to update the date picker to a given date (day,month,year) I used this code
date.updateDate(year, month, day);
where day,month and year are of type int. I have an exception while debugging "source not found" at this line. what's the wrong with my code?? thanks
Upvotes: 0
Views: 1020
Reputation: 3294
Is date your view?
view.updateDate(year, month, day)
ex:
mDateListener = new DatePicker.OnDateChangedListener() {
public void onDateChanged(DatePicker view, int year, int month, int day) {
if (prompt.isReadOnly()) {
if (prompt.getAnswerValue() != null) {
Date d = (Date) prompt.getAnswerObject();
view.updateDate(d.getYear() + YEARSHIFT, d.getMonth(), d.getDate());
} else {
view.updateDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c
.get(Calendar.DAY_OF_MONTH));
}
} else {
// handle leap years and number of days in month
// TODO
// http://code.google.com/p/android/issues/detail?id=2081
c.set(year, month, 1);
int max = c.getActualMaximum(Calendar.DAY_OF_MONTH);
if (day > max) {
view.updateDate(year, month, max);
} else {
view.updateDate(year, month, day);
}
}
}
};
Upvotes: 0