當前位置: 首頁>>代碼示例>>Java>>正文


Java DatePickerDialog.getDatePicker方法代碼示例

本文整理匯總了Java中android.app.DatePickerDialog.getDatePicker方法的典型用法代碼示例。如果您正苦於以下問題:Java DatePickerDialog.getDatePicker方法的具體用法?Java DatePickerDialog.getDatePicker怎麽用?Java DatePickerDialog.getDatePicker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.DatePickerDialog的用法示例。


在下文中一共展示了DatePickerDialog.getDatePicker方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateDialog

import android.app.DatePickerDialog; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    DatePickerDialog dialog = new DatePickerDialog(getActivity(),
            R.style.CustomDatePickerDialogTheme, this, mParent.mYear, mParent.mMonth, 1);

    DatePicker datePicker = dialog.getDatePicker();

    // Limit range.
    Calendar c = mParent.getCalendar();
    datePicker.setMinDate(c.getTimeInMillis());
    c.set(Calendar.YEAR, mParent.mYear + CC_EXP_YEARS_COUNT - 1);
    datePicker.setMaxDate(c.getTimeInMillis());

    // Remove day.
    datePicker.findViewById(getResources().getIdentifier("day", "id", "android"))
            .setVisibility(View.GONE);
    return dialog;
}
 
開發者ID:googlesamples,項目名稱:android-AutofillFramework,代碼行數:19,代碼來源:CreditCardExpirationDatePickerView.java

示例2: onCreateDialog

import android.app.DatePickerDialog; //導入方法依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Uses the current date as the default date in the picker
    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(getActivity(), this, year, month, day);
    DatePicker datePicker = dialog.getDatePicker();

    datePicker.setCalendarViewShown(false);
    numOfCalls = 0;

    return dialog;
}
 
開發者ID:mr-kojo,項目名稱:Veggietizer,代碼行數:17,代碼來源:DatePickerFragment.java

示例3: createDialog

import android.app.DatePickerDialog; //導入方法依賴的package包/類
static Dialog createDialog(
    Bundle args, Context activityContext, @Nullable OnDateSetListener onDateSetListener) {
  final Calendar c = Calendar.getInstance();
  if (args != null && args.containsKey(DatePickerDialogModule.ARG_DATE)) {
    c.setTimeInMillis(args.getLong(DatePickerDialogModule.ARG_DATE));
  }
  final int year = c.get(Calendar.YEAR);
  final int month = c.get(Calendar.MONTH);
  final int day = c.get(Calendar.DAY_OF_MONTH);

  DatePickerMode mode = DatePickerMode.DEFAULT;
  if (args != null && args.getString(DatePickerDialogModule.ARG_MODE, null) != null) {
    mode = DatePickerMode.valueOf(args.getString(DatePickerDialogModule.ARG_MODE).toUpperCase(Locale.US));
  }

  DatePickerDialog dialog = null;

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    switch (mode) {
      case CALENDAR:
        dialog = new DismissableDatePickerDialog(activityContext,
          activityContext.getResources().getIdentifier("CalendarDatePickerDialog", "style", activityContext.getPackageName()),
          onDateSetListener, year, month, day);
        break;
      case SPINNER:
        dialog = new DismissableDatePickerDialog(activityContext,
          activityContext.getResources().getIdentifier("SpinnerDatePickerDialog", "style", activityContext.getPackageName()),
          onDateSetListener, year, month, day);
        break;
      case DEFAULT:
        dialog = new DismissableDatePickerDialog(activityContext, onDateSetListener, year, month, day);
        break;
    }
  } else {
    dialog = new DismissableDatePickerDialog(activityContext, onDateSetListener, year, month, day);

    switch (mode) {
      case CALENDAR:
        dialog.getDatePicker().setCalendarViewShown(true);
        dialog.getDatePicker().setSpinnersShown(false);
        break;
      case SPINNER:
        dialog.getDatePicker().setCalendarViewShown(false);
        break;
    }
  }

  final DatePicker datePicker = dialog.getDatePicker();

  if (args != null && args.containsKey(DatePickerDialogModule.ARG_MINDATE)) {
    // Set minDate to the beginning of the day. We need this because of clowniness in datepicker
    // that causes it to throw an exception if minDate is greater than the internal timestamp
    // that it generates from the y/m/d passed in the constructor.
    c.setTimeInMillis(args.getLong(DatePickerDialogModule.ARG_MINDATE));
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    datePicker.setMinDate(c.getTimeInMillis());
  } else {
    // This is to work around a bug in DatePickerDialog where it doesn't display a title showing
    // the date under certain conditions.
    datePicker.setMinDate(DEFAULT_MIN_DATE);
  }
  if (args != null && args.containsKey(DatePickerDialogModule.ARG_MAXDATE)) {
    // Set maxDate to the end of the day, same reason as for minDate.
    c.setTimeInMillis(args.getLong(DatePickerDialogModule.ARG_MAXDATE));
    c.set(Calendar.HOUR_OF_DAY, 23);
    c.set(Calendar.MINUTE, 59);
    c.set(Calendar.SECOND, 59);
    c.set(Calendar.MILLISECOND, 999);
    datePicker.setMaxDate(c.getTimeInMillis());
  }

  return dialog;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:77,代碼來源:DatePickerDialogFragment.java


注:本文中的android.app.DatePickerDialog.getDatePicker方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。