本文整理汇总了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;
}
示例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;
}