@TargetApi(Build.VERSION_CODES.HONEYCOMB)
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    setRetainInstance(true);

    // Use the current date as the default date in the picker
    final Calendar c = mCal;
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);

    // Create a new instance of DatePickerDialog and return it
    DatePickerDialog pickerDialog;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      pickerDialog = new DatePickerDialog(getActivity(), mListener, year, month, day);
      if (mMinCal != null) {
        pickerDialog.getDatePicker().setMinDate(mMinCal.getTimeInMillis());
      }
      if (mMaxCal != null) {
        pickerDialog.getDatePicker().setMaxDate(mMaxCal.getTimeInMillis());
      }
    } else {
      pickerDialog =
          new DatePickerDialog(getActivity(), mListener, year, month, day) {
            @Override
            public void onDateChanged(DatePicker view, int year, int month, int day) {
              if (isAfterMinDate(year, month, day) && isBeforeMaxDate(year, month, day)) {
                view.updateDate(year, month, day);
              }
            }
          };
    }

    return pickerDialog;
  }
 protected Dialog onCreateDialog(int id) {
   if (id == DIALOG_DATE) {
     Calendar c = Calendar.getInstance();
     c.set(Calendar.DAY_OF_YEAR, 1);
     DatePickerDialog tpd = new DatePickerDialog(this, myCallBack, myYear, myMonth, myDay);
     tpd.getDatePicker().setMinDate(c.getTimeInMillis());
     c.set(Calendar.DAY_OF_YEAR, 366);
     tpd.getDatePicker().setMaxDate(c.getTimeInMillis());
     return tpd;
   }
   return super.onCreateDialog(id);
 }
 /**
  * Called when user clicked on initial date EditText
  *
  * @param view target
  */
 public void onInitialDateClick(View view) {
   DatePickerDialog datePickerDialog =
       new DatePickerDialog(
           activity,
           onInitialDateSetListener,
           initialDateCalendar.get(Calendar.YEAR),
           initialDateCalendar.get(Calendar.MONTH),
           initialDateCalendar.get(Calendar.DAY_OF_MONTH));
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
     datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
   }
   if (event.hasEndDate() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
     datePickerDialog.getDatePicker().setMaxDate(endDateCalendar.getTimeInMillis());
   }
   datePickerDialog.show();
 }
 /**
  * Called when user clicked on end date EditText
  *
  * @param view target
  */
 public void onEndDateClick(View view) {
   DatePickerDialog datePickerDialog =
       new DatePickerDialog(
           activity,
           onEndDateSetListener,
           endDateCalendar.get(Calendar.YEAR),
           endDateCalendar.get(Calendar.MONTH),
           endDateCalendar.get(Calendar.DAY_OF_MONTH));
   if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
     datePickerDialog.getDatePicker().setMinDate(initialDateCalendar.getTimeInMillis());
   }
   datePickerDialog.show();
 }
  public void selectDatePayment(View view) {
    int[] dayMonthYear = rowDate.getDayMonthYear();
    DatePickerDialog date =
        new DatePickerDialog(
            this,
            new DatePickerDialog.OnDateSetListener() {

              @Override
              public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                rowDate.setValueInfo((monthOfYear + 1) + "/" + dayOfMonth + "/" + year);
              }
            },
            dayMonthYear[2],
            dayMonthYear[0] - 1,
            dayMonthYear[1]);
    date.getDatePicker().setCalendarViewShown(false);
    Calendar cal = Calendar.getInstance();
    cal.set(
        cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
    date.getDatePicker().setMinDate(cal.getTimeInMillis());
    date.show();
  }
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.et_dob:
        Calendar calendar = Calendar.getInstance();
        int mYear = calendar.get(Calendar.YEAR);
        int mMonth = calendar.get(Calendar.MONTH);
        int mDay = calendar.get(Calendar.DAY_OF_MONTH);
        DatePickerDialog datePickerDialog =
            new DatePickerDialog(
                RegisterActivity.this,
                new DatePickerDialog.OnDateSetListener() {
                  @Override
                  public void onDateSet(
                      DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                    mEtDOB.setText(monthOfYear + 1 + "/" + dayOfMonth + "/" + year);
                    mEtPhone.requestFocus();
                  }
                },
                mYear,
                mMonth,
                mDay);

        datePickerDialog.getDatePicker().setMaxDate(new Date().getTime());
        datePickerDialog.show();
        break;

      case R.id.btn_register:
        String sName = mEtName.getText().toString();
        String sEmail = mEtEmail.getText().toString();
        String sPassword = mEtPassword.getText().toString();
        String sRePassword = mEtRePassword.getText().toString();
        // Log.d("RegisterActivity", sSex);

        String sDOB = mEtDOB.getText().toString();
        String sPhoneNumber = mEtPhone.getText().toString();
        VerifyUserDetails verifyUserDetails =
            new VerifyUserDetails(sName, sEmail, sPassword, sRePassword, sPhoneNumber);

        if (verifyUserDetails.verify()) {
          User registeredUser = new User(sName, sEmail, sPassword, sDOB, sPhoneNumber, sSex);
          registerUser(registeredUser);
          break;
        } else {
          Toast.makeText(this, verifyUserDetails.verificationResult, Toast.LENGTH_LONG).show();
          break;
        }
    }
  }
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

      DatePickerDialog dpd;

      try {
        // Use the current date - 21 years as the default date in the picker
        // Use dob if already exists
        Calendar c = Calendar.getInstance();
        int year;
        int month;
        int day;

        if (user.getName() != null && user.getName() != "") {
          year = Integer.parseInt(user.getBirthdate("yyyy"));
          month = Integer.parseInt(user.getBirthdate("M")) - 1;
          day = Integer.parseInt(user.getBirthdate("d"));
        } else {
          year = c.get(Calendar.YEAR);
          month = c.get(Calendar.MONTH);
          day = c.get(Calendar.DAY_OF_MONTH);
          year = year - 21;
        }

        // Create a new instance of DatePickerDialog and return it
        dpd = new DatePickerDialog(getActivity(), this, year, month, day);
        dpd.getDatePicker().setMinDate(dpd.getDatePicker().getMinDate());
        dpd.getDatePicker().setMaxDate(c.getTimeInMillis());
        c.clear();
        c = null;
      } catch (Exception e) {
        dpd = null;
        Log.d("", e.getMessage());
      }
      return dpd;
    }
 @Override
 public void onClick(View v) {
   int id = v.getId();
   if (id == R.id.event_location) {
     Intent i = new Intent(context, MapsActivity.class);
     CreateEventActivity.this.startActivity(i);
   } else if (id == R.id.event_date) {
     DPD = new DatePickerDialog(context, mDateSetListener, 2013, 11, 30);
     DPD.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
     DPD.show();
   } else if (id == R.id.event_time) {
     TPD =
         new TimePickerDialog(
             context, mTimeSetListener, Calendar.HOUR_OF_DAY, Calendar.MINUTE, true);
     TPD.show();
   }
 }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current date as the default date in the picker
    final Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);

    if (dateChanged) {
      DatePickerDialog TheThingToReturn =
          new DatePickerDialog(
              getActivity(), AddMatchActivity.TheOnDateSetListener, Year, MonthOfYear, DayOfMonth);
      TheThingToReturn.getDatePicker().setCalendarViewShown(true);
      TheThingToReturn.getDatePicker().setSpinnersShown(true);
      return TheThingToReturn;
    } else {
      return new DatePickerDialog(
          getActivity(), AddMatchActivity.TheOnDateSetListener, year, month, day);
    }
  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    //

    GregorianCalendar GC = (GregorianCalendar) GregorianCalendar.getInstance();
    GC.add(GregorianCalendar.DAY_OF_MONTH, 1);
    int year = GC.get(Calendar.YEAR);
    int month = GC.get(Calendar.MONTH);
    int day = GC.get(Calendar.DAY_OF_MONTH);
    long min = GC.getTimeInMillis();
    GC.add(GregorianCalendar.YEAR, 1);
    long max = GC.getTimeInMillis();
    DatePickerDialog d = new DatePickerDialog(getActivity(), this, year, month, day);
    DatePicker dp = d.getDatePicker();
    dp.setMinDate(min);
    dp.setMaxDate(max);
    return d;
    // Create a new instance of DatePickerDialog and return it

  }
Beispiel #11
0
  public void showDatePickerDialog(
      int year, int month, int day, final DatePickerLister datePickerLister) {
    mYear = year;
    mMonth = month;
    mDay = day;
    if (mDateDialog == null) {
      mDateDialog = new DatePickerDialog(mContext, onDateSetListener, mYear, mMonth, mDay);
    }
    DatePicker dp = mDateDialog.getDatePicker();
    dp.setMaxDate(Calendar.getInstance().getTimeInMillis()); // 设置最大日期
    mDateDialog.setTitle(R.string.userinfo_select_birthday);
    mDateDialog.setButton(
        AlertDialog.BUTTON_NEGATIVE,
        mContext.getResources().getString(R.string.common_cancel),
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            mDateDialog = null;
          }
        });
    mDateDialog.setButton(
        AlertDialog.BUTTON_POSITIVE,
        mContext.getResources().getString(R.string.common_sure),
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            mYear = mDateDialog.getDatePicker().getYear();
            mMonth = mDateDialog.getDatePicker().getMonth();
            mDay = mDateDialog.getDatePicker().getDayOfMonth();
            datePickerLister.onDatePicker(mYear, mMonth, mDay);
            dialog.dismiss();
            mDateDialog = null;
          }
        });
    mDateDialog.show();
  }
Beispiel #12
0
 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
 private static void forceTitleUpdate(
     final int year, final int month, final int day, final DatePickerDialog dialog) {
   dialog.onDateChanged(dialog.getDatePicker(), year, month, day);
 }