标签:android
mDateDialog.setButton(DialogInterface.BUTTON_POSITIVE, "确定", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { resetDialog(mDateDialog, true); Field field; try { field = dialog.getClass().getDeclaredField( "mCalendar"); field.setAccessible(true); Calendar c = (Calendar) field.get(dialog); calendar.set(Calendar.YEAR, c.get(Calendar.YEAR)); calendar.set(Calendar.MONTH, c.get(Calendar.MONTH)); calendar.set(Calendar.DAY_OF_MONTH, c.get(Calendar.DAY_OF_MONTH)); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); Calendar currentCalendar = Calendar .getInstance(Locale.CHINA); currentCalendar.set(Calendar.HOUR, 0); currentCalendar.set(Calendar.MINUTE, 0); currentCalendar.set(Calendar.SECOND, 0); currentCalendar.set(Calendar.MILLISECOND, 0); if (currentCalendar.before(calendar) || currentCalendar.equals(calendar)) { String str = calendar.get(Calendar.YEAR) + "年" + (calendar.get(Calendar.MONTH) + 1) + "月" + calendar.get(Calendar.DAY_OF_MONTH) + "日"; text_value_product_deli_time.setText(str); } else { resetDialog(mDateDialog, false); ToastUtils.t(mContext, "您不能穿越"); } } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } });
======DatePickerDialog时间选的符合标准才消失======
标签:android
原文地址:http://blog.csdn.net/soulofandroid/article/details/43445705