Beispiel #1
0
 @Override
 protected void onPrepareDialog(int id, Dialog dialog) {
   super.onPrepareDialog(id, dialog);
   switch (id) {
     case DATE_DIALOG_ID:
       // Handle any DatePickerDialog initialization here
       DatePickerDialog dateDialog = (DatePickerDialog) dialog;
       int iDay, iMonth, iYear;
       // Check for date of birth preference
       if (mGameSettings.contains(GAME_PREFERENCES_DOB)) {
         // Retrieve Birth date setting from preferences
         long msBirthDate = mGameSettings.getLong(GAME_PREFERENCES_DOB, 0);
         Time dateOfBirth = new Time();
         dateOfBirth.set(msBirthDate);
         iDay = dateOfBirth.monthDay;
         iMonth = dateOfBirth.month;
         iYear = dateOfBirth.year;
       } else {
         Calendar cal = Calendar.getInstance();
         // Today’s date fields
         iDay = cal.get(Calendar.DAY_OF_MONTH);
         iMonth = cal.get(Calendar.MONTH);
         iYear = cal.get(Calendar.YEAR);
       }
       // Set the date in the DatePicker to the date of birth OR to the
       // current date
       dateDialog.updateDate(iYear, iMonth, iDay);
       return;
   }
 }
 @Override
 protected void onPrepareDialog(int id, Dialog dialog) {
   switch (id) {
     case DATE_DIALOG_ID:
       dialog.setTitle("运抵期限");
       ((DatePickerDialog) dialog).updateDate(mYear, mMonth, mDay);
       break;
   }
 }
Beispiel #3
0
 @Override
 protected void onPrepareDialog(int id, Dialog dialog) {
   switch (id) {
     case FROM_DATE_DIALOG_ID:
       ((DatePickerDialog) dialog)
           .updateDate(
               fromCalendar.get(Calendar.YEAR),
               fromCalendar.get(Calendar.MONTH),
               fromCalendar.get(Calendar.DAY_OF_MONTH));
       break;
     case TO_DATE_DIALOG_ID:
       ((DatePickerDialog) dialog)
           .updateDate(
               toCalendar.get(Calendar.YEAR),
               toCalendar.get(Calendar.MONTH),
               toCalendar.get(Calendar.DAY_OF_MONTH));
       break;
   }
 }
 @Override
 protected void onPrepareDialog(int id, Dialog dialog) {
   switch (id) {
     case TIME_DIALOG_ID:
       ((TimePickerDialog) dialog).updateTime(mHour, mMinute);
       break;
     case DATE_DIALOG_ID:
       ((DatePickerDialog) dialog).updateDate(mYear, mMonth, mDay);
       break;
   }
 }
 @Override
 public Dialog onCreateDialog(Bundle savedInstanceState) {
   final Calendar calendar = Calendar.getInstance();
   DatePickerDialog datePickerDialog =
       new DatePickerDialog(
           getActivity(),
           this,
           calendar.get(Calendar.YEAR),
           calendar.get(Calendar.MONTH),
           calendar.get(Calendar.DAY_OF_MONTH));
   if (scheduledTimeHolder.getTimestamp() != null) {
     String scheduledDate = scheduledTimeHolder.getDate();
     String[] sd = scheduledDate.split("-");
     datePickerDialog.updateDate(
         Integer.parseInt(sd[2]), Integer.parseInt(sd[1]), Integer.parseInt(sd[0]));
   }
   return datePickerDialog;
 }
  @Override
  protected void onPrepareDialog(int id, Dialog dialog) {
    switch (id) {
      case TIME_DIALOG_ID:
        ((TimePickerDialog) dialog)
            .updateTime(mCalendar.get(Calendar.HOUR_OF_DAY), mCalendar.get(Calendar.MINUTE));
        break;
      case DATE_DIALOG_ID:
        ((DatePickerDialog) dialog)
            .updateDate(
                mCalendar.get(Calendar.YEAR),
                mCalendar.get(Calendar.MONTH),
                mCalendar.get(Calendar.DAY_OF_MONTH));
        break;

      case DIALOG_MULTIPLE_CATEGORY:
        final AlertDialog alert = (AlertDialog) dialog;
        final ListView list = alert.getListView();
        // been
        // selected, then uncheck
        // selected categories
        if (mVectorCategories.size() > 0) {
          for (String s : mVectorCategories) {
            try {
              // @inoran fix
              if (list != null) {
                list.setItemChecked(mCategoryLength - Integer.parseInt(s), true);
              }
            } catch (NumberFormatException e) {
              log("NumberFormatException", e);
            }
          }
        } else {
          if (list != null) {
            list.clearChoices();
          }
        }

        break;
    }
  }