コード例 #1
0
ファイル: MyDiary.java プロジェクト: skyidelete/MyApplication
  void showDatePickerDialog() {
    final int tempYear = cYear;
    final int tempMonth = cMonth;
    final int tempDay = cDay;

    DatePickerDialog dialog =
        new DatePickerDialog(
            this,
            new DatePickerDialog.OnDateSetListener() {
              @Override
              public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                cYear = year;
                cMonth = monthOfYear + 1;
                cDay = dayOfMonth;
                loadDiary();
              }
            },
            cYear,
            cMonth - 1,
            cDay);

    dialog.setOnCancelListener(
        new DialogInterface.OnCancelListener() {
          @Override
          public void onCancel(DialogInterface arg0) {
            cYear = tempYear;
            cMonth = tempMonth;
            cDay = tempDay;
          }
        });

    dialog.setTitle("날짜 선택");

    dialog.show();
  }
コード例 #2
0
ファイル: Temp.java プロジェクト: Drakuwa/aFridge
  public void exp_date() {

    Calendar c = Calendar.getInstance();

    mYear = c.get(Calendar.YEAR);
    mMonth = c.get(Calendar.MONTH) + 1;
    mDay = c.get(Calendar.DAY_OF_MONTH);

    DatePickerDialog.OnDateSetListener mDateSetListener =
        new DatePickerDialog.OnDateSetListener() {

          public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            mYear = year;
            mMonth = monthOfYear + 1;
            mDay = dayOfMonth;
            exp_date =
                Integer.toString(mDay)
                    + "-"
                    + Integer.toString(mMonth)
                    + "-"
                    + Integer.toString(mYear);
          }
        };

    DatePickerDialog dialog = new DatePickerDialog(this, mDateSetListener, mYear, mMonth - 1, mDay);
    dialog.show();
  }
コード例 #3
0
ファイル: UtilSettings.java プロジェクト: iamukasa/Ultipedia
 @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;
   }
 }
コード例 #4
0
  private void createDateEditDialog(
      int year, int month, int dayOfMonth, final Date date, final boolean isStartDate) {

    final GregorianCalendar gc = new GregorianCalendar();
    gc.setTime(date);

    DatePickerDialog dialog =
        new DatePickerDialog(
            this,
            new DatePickerDialog.OnDateSetListener() {

              @Override
              public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {

                gc.set(Calendar.YEAR, year);
                gc.set(Calendar.MONTH, monthOfYear);
                gc.set(Calendar.DAY_OF_MONTH, dayOfMonth);

                if (isStartDate) {
                  ponto.setStartDate(gc.getTime());
                  startDate.setText(sdfDate.format(gc.getTime()));
                } else {
                  ponto.setFinishDate(gc.getTime());
                  finishDate.setText(sdfDate.format(gc.getTime()));
                }
                repository.saveOrUpdate(ponto);
              }
            },
            year,
            month,
            dayOfMonth);
    dialog.show();
  }
コード例 #5
0
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
      // Use the current date as the default date in the picker
      int year = 0;
      int month = 0;
      int day = 0;
      /*if (userBirthdate != null) {
          year = userBirthdate.getYear();
          month = userBirthdate.getMonthOfYear() - 1;
          day = userBirthdate.getDayOfMonth();
      } else {*/
      LocalDateTime now = LocalDateTime.now();
      year = now.getYear();
      month = now.getMonthOfYear();
      day = now.getDayOfMonth();
      // }

      DatePickerDialog dateDlg = new DatePickerDialog(getActivity(), this, year, month, day);
      dateDlg.setMessage(getString(R.string.add_date_dialog_title));
      Calendar calendar = Calendar.getInstance();
      calendar.set(Calendar.MONTH, calendar.getActualMaximum(Calendar.MONTH));
      calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
      // dateDlg.getDatePicker().setMaxDate(calendar.getTimeInMillis());

      // Create a new instance of DatePickerDialog and return it
      return dateDlg;
    }
コード例 #6
0
  @Click(R.id.date_text)
  public void showDatePicker() {

    // Launch Date Picker Dialog
    DatePickerDialog dpd =
        new DatePickerDialog(
            getActivity(),
            new DatePickerDialog.OnDateSetListener() {

              @Override
              public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                // Display Selected date in textbox

                String day = "";
                String month = "";
                if (dayOfMonth < 10) day = "0" + dayOfMonth;
                else day = "" + dayOfMonth;
                if ((monthOfYear + 1) < 10) month = "0" + (monthOfYear + 1);
                else month = "" + (monthOfYear + 1);
                dateText.setText(year + "-" + month + "-" + day);
              }
            },
            year,
            month,
            day);
    dpd.show();
  }
コード例 #7
0
 @Override
 public void onClick(View view) {
   switch (view.getId()) {
     case R.id.btn_back:
       this.finish();
       break;
     case R.id.tv_time:
       Calendar c = Calendar.getInstance();
       DatePickerDialog datePicker =
           new DatePickerDialog(
               ReleaseGroupInfoAc.this,
               new OnDateSetListener() {
                 @Override
                 public void onDateSet(
                     DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                   Toast.makeText(
                           ReleaseGroupInfoAc.this,
                           year + "年 " + (monthOfYear + 1) + "月 " + dayOfMonth + "日",
                           Toast.LENGTH_SHORT)
                       .show();
                   tv_time.setText(year + "-" + (monthOfYear + 1) + "- " + dayOfMonth + "-");
                 }
               },
               c.get(Calendar.YEAR),
               c.get(Calendar.MONTH),
               c.get(Calendar.DAY_OF_MONTH)) {
             @Override
             protected void onStop() {
               // super.onStop();
             }
           };
       datePicker.show();
       break;
   }
 }
コード例 #8
0
  private void showDatepicker() {
    if (!locationListeners.isEmpty()) {
      return;
    }

    final DatePickerDialog datePickerDialog =
        new DatePickerDialog(
            this,
            new DatePickerDialog.OnDateSetListener() {
              @Override
              public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                Calendar c = Calendar.getInstance();
                c.set(year, monthOfYear, dayOfMonth);

                if (DateTimes.isSameDay(mDate, c)) {
                  return;
                }

                mDate.set(year, monthOfYear, dayOfMonth);

                final TextView txtDate = (TextView) findViewById(R.id.txtDate);
                txtDate.setText(DateTimes.dateFormat().format(mDate));

                GPSHelper.loadTrackings(mDate);
                updateList();
              }
            },
            mDate.get(Calendar.YEAR),
            mDate.get(Calendar.MONTH),
            mDate.get(Calendar.DAY_OF_MONTH));

    datePickerDialog.show();
  }
コード例 #9
0
ファイル: ServiceDatesFragment.java プロジェクト: epam/JDI
 @Override
 public void onClick(View v) {
   if (v.getId() == R.id.date) {
     if (date == null) {
       date = Calendar.getInstance();
     }
     DatePickerDialog datePickerDialog =
         new DatePickerDialog(
             getContext(),
             ServiceDatesFragment.this,
             date.get(Calendar.YEAR),
             date.get(Calendar.MONTH),
             date.get(Calendar.DAY_OF_MONTH));
     datePickerDialog.show();
   } else {
     if (time == null) {
       time = Calendar.getInstance();
     }
     TimePickerDialog datePickerDialog =
         new TimePickerDialog(
             getContext(),
             ServiceDatesFragment.this,
             time.get(Calendar.HOUR_OF_DAY),
             time.get(Calendar.MINUTE),
             true);
     datePickerDialog.show();
   }
 }
コード例 #10
0
  @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;
  }
コード例 #11
0
 private void showDatePicker() {
   Calendar calendar = Calendar.getInstance();
   int year = calendar.get(Calendar.YEAR);
   int month = calendar.get(Calendar.MONTH);
   int day = calendar.get(Calendar.DAY_OF_MONTH);
   DatePickerDialog dateDialog =
       new DatePickerDialog(getActivity(), dateSetListener, year, month, day);
   dateDialog.show();
 }
コード例 #12
0
  @Override
  public void onClick(View v) {

    if (v == yes) {
      if (validate()) {
        if (repeatRepRadio.isChecked()) {
          rule.setCount(Integer.parseInt(repeatRepEdit.getText().toString()));
          rule.setUntil(null);
        } else {
          rule.setCount(null);
          rule.setUntil(DateUtil.convertDateToRRULE(repeatUntilDate.getText().toString()));
        }

        dismiss();
      }

    } else if (v == no) {
      cancelClicked = true;
      cancel();
    } else if (v == repeatRepEdit || v == repeatRepRadio || v == repeatRepRow) {

      repeatUntilRadio.setChecked(false);
      repeatRepRadio.setChecked(true);
      repeatRepEdit.setEnabled(true);
      repeatRepEdit.setFocusable(true);
      previousSelectedRadio = repeatRepRadio;

    } else if (v == repeatUntilDate || v == repeatUntilRadio || v == repeatUntilRow) {
      repeatRepRadio.setChecked(false);
      repeatUntilRadio.setChecked(true);
      repeatRepEdit.setEnabled(false);
      DatePickerDialog dialog = null;
      if (!StringUtils.isEmpty(repeatUntilDate.getText().toString())) {
        GregorianCalendar cal =
            DateUtil.getCalendarFromString(repeatUntilDate.getText().toString());
        dialog =
            new DatePickerDialog(
                activity,
                datePickerListener,
                cal.get(Calendar.YEAR),
                cal.get(Calendar.MONTH),
                cal.get(Calendar.DAY_OF_MONTH));
      } else {
        dialog =
            new DatePickerDialog(
                activity,
                datePickerListener,
                eventDate.get(Calendar.YEAR),
                eventDate.get(Calendar.MONTH),
                eventDate.get(Calendar.DAY_OF_MONTH));
      }

      dialog.setOnDismissListener(datePickerDismissListener);

      dialog.show();
    }
  }
コード例 #13
0
ファイル: Base.java プロジェクト: Yuchinin/ifarm
 public void showDatePickerDialog(View v) {
   Calendar c = Calendar.getInstance();
   int year = c.get(Calendar.YEAR);
   int month = c.get(Calendar.MONTH);
   int day = c.get(Calendar.DAY_OF_MONTH);
   DatePickerDialog dialog =
       new DatePickerDialog(v.getContext(), datePickerListener, year - 18, month, day);
   dialog.show();
 }
コード例 #14
0
ファイル: MainActivity.java プロジェクト: StingHuang/Money
 @Override
 public void onClick(View v) {
   // TODO Auto-generated method stub
   DatePickerDialog dpd =
       new DatePickerDialog(MainActivity.this, datePickerDlgOnDateSet, mYear, mMonth, mDay);
   dpd.setTitle("Choose Date");
   dpd.setMessage("");
   dpd.setCancelable(false);
   dpd.show();
 }
コード例 #15
0
ファイル: AddReportFragment.java プロジェクト: haikuowuya/xh
 private void selectDate() {
   DatePickerDialog.OnDateSetListener callback =
       new DatePickerDialog.OnDateSetListener() {
         public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
           mTvDate.setText(year + "-" + (1 + monthOfYear) + "-" + dayOfMonth);
         }
       };
   DatePickerDialog datePickerDialog = new DatePickerDialog(mActivity, callback, 2015, 9, 1);
   datePickerDialog.show();
 }
コード例 #16
0
 private void showDateDialog() {
   final Calendar c = Calendar.getInstance();
   DatePickerDialog dp =
       new DatePickerDialog(
           _context,
           this,
           c.get(Calendar.YEAR),
           c.get(Calendar.MONTH),
           c.get(Calendar.DAY_OF_MONTH));
   dp.show();
 }
コード例 #17
0
 // 日付出力関数
 public void datePickerShow1() {
   Calendar calendar = Calendar.getInstance();
   DatePickerDialog dateDialog =
       new DatePickerDialog(
           this,
           varDateSetListener_day1,
           calendar.get(Calendar.YEAR),
           calendar.get(Calendar.MONTH),
           calendar.get(Calendar.DAY_OF_MONTH));
   dateDialog.show();
 }
コード例 #18
0
ファイル: BaseActivity.java プロジェクト: cyiwon/iwon
  protected void showtimedialog() {
    DatePickerDialog dialog =
        new DatePickerDialog(
            this,
            this,
            calendar.get(Calendar.YEAR),
            calendar.get(Calendar.MONTH),
            calendar.get(Calendar.DAY_OF_MONTH));

    dialog.show();
  }
コード例 #19
0
 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);
 }
コード例 #20
0
 /**
  * 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();
 }
コード例 #21
0
  @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;
        }
    }
  }
コード例 #22
0
 @OnClick(R.id.rlDate)
 public void pickDate() {
   Calendar cal = Calendar.getInstance(TimeZone.getDefault());
   DatePickerDialog datePickerDialog =
       new DatePickerDialog(
           this,
           DatePickerDialog.THEME_HOLO_LIGHT,
           datePickerListener,
           cal.get(Calendar.YEAR),
           cal.get(Calendar.MONTH),
           cal.get(Calendar.DAY_OF_MONTH));
   datePickerDialog.setCancelable(false);
   datePickerDialog.setTitle("Select the date");
   datePickerDialog.show();
 }
コード例 #23
0
  public DatePickerDialog builder() {

    Calendar newCalendar = Calendar.getInstance();

    // Data de Nascimento
    DatePickerDialog dataPickerDialog =
        new DatePickerDialog(
            this.activity,
            this,
            newCalendar.get(Calendar.YEAR),
            newCalendar.get(Calendar.MONTH),
            newCalendar.get(Calendar.DAY_OF_MONTH));
    dataPickerDialog.setTitle(getTitleDate()); // constante

    return dataPickerDialog;
  }
コード例 #24
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case R.id.today_action_reload:
        getData(mUrl);
        break;
      case R.id.today_action_choose:
        DatePickerDialog dlg = new DatePickerDialog(this, this, year, month - 1, day);
        dlg.show();
        break;
      default:
        break;
    }
    return true;
  }
コード例 #25
0
 /**
  * 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();
 }
コード例 #26
0
  @Override
  public void onClick(View v) {

    if (v == dueDateText) {
      dueDatePickerDialog.show();
    }
  }
コード例 #27
0
 @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();
   }
 }
コード例 #28
0
 @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;
 }
コード例 #29
0
 @Override
 protected void onPrepareDialog(int id, Dialog dialog) {
   switch (id) {
     case DATE_DIALOG_ID:
       dialog.setTitle("运抵期限");
       ((DatePickerDialog) dialog).updateDate(mYear, mMonth, mDay);
       break;
   }
 }
コード例 #30
0
ファイル: NotesList.java プロジェクト: jeongjaehong/webbibles
 @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;
   }
 }