From 28104e1de5595a22a6987181b13ddeb192739afd Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Sun, 19 Dec 2010 16:03:07 -0800 Subject: 3298147 DatePicker dialog does not provide mechanism for specifying range from which to select Change-Id: Ib5dd7db90ccc5b4d984914c481118049ac3648fe --- core/java/android/app/DatePickerDialog.java | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'core/java/android/app') diff --git a/core/java/android/app/DatePickerDialog.java b/core/java/android/app/DatePickerDialog.java index 448b3ef..e6e55ee 100644 --- a/core/java/android/app/DatePickerDialog.java +++ b/core/java/android/app/DatePickerDialog.java @@ -21,7 +21,6 @@ import com.android.internal.R; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; -import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -118,6 +117,28 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener, mDatePicker.init(year, month, day, null); } + /** + * Sets the range of years in which dates can be selected. + *

+ * Note: If the range is set to a value that does not include the currently + * selected date the value of the picker shown by this dialog will be + * updated to the closest date in the range. + *

+ * + * @param startYear The start year of the range. + * @param endYear The end year of the range. + */ + public void setRange(int startYear, int endYear) { + mDatePicker.setRange(startYear, endYear); + } + + /** + * Sets the current date. + * + * @param year The date year. + * @param monthOfYear The date month. + * @param dayOfMonth The date day of month. + */ public void updateDate(int year, int monthOfYear, int dayOfMonth) { mDatePicker.updateDate(year, monthOfYear, dayOfMonth); } -- cgit v1.1