OSDN Git Service

Force-commit changes on accept in spinner-style DatePickerDialog
authorAlan Viverette <alanv@google.com>
Wed, 14 Jan 2015 01:34:17 +0000 (17:34 -0800)
committerAlan Viverette <alanv@google.com>
Wed, 14 Jan 2015 01:34:17 +0000 (17:34 -0800)
Bug: 19005472
Change-Id: If500c7305282a5055b4617c242871e04d91c0bc3

core/java/android/app/DatePickerDialog.java

index f79d32b..3fbbdff 100644 (file)
@@ -131,6 +131,9 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener,
         switch (which) {
             case BUTTON_POSITIVE:
                 if (mDateSetListener != null) {
+                    // Clearing focus forces the dialog to commit any pending
+                    // changes, e.g. typed text in a NumberPicker.
+                    mDatePicker.clearFocus();
                     mDateSetListener.onDateSet(mDatePicker, mDatePicker.getYear(),
                             mDatePicker.getMonth(), mDatePicker.getDayOfMonth());
                 }