在Android DatePickerDialog最大日期 [英] Max Date on an Android DatePickerDialog

查看:142
本文介绍了在Android DatePickerDialog最大日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个最大年份上设置DatePickerDialog,我用,但我无法找到这样做的任何机制。说明文档中提到getDatePicker()作为DatePickerDialog的公共方法。所以,我想,也许,可用于获取的DatePicker,然后我可以设置最大日期,但我得到方法未定义错误,当我尝试获取的DatePicker。

I need to set a max year on the DatePickerDialog that I am using but I am unable to find any mechanism of doing that. The documentation mentions getDatePicker () as a public method of the DatePickerDialog. So, I thought, perhaps, that can be used to get the DatePicker and then I could set the max date but I get "Method undefined" error when I try to get the DatePicker.

这是我怎么想获得我的onCreateDialog内的DatePicker。

This is how I am trying to get the DatePicker inside my onCreateDialog.

DatePickerDialog d = new DatePickerDialog(this, dep_dateListener, mYear,
                      mMonth, mDay);
DatePicker dp = d.getDatePicker();
dp.setMaxDate(maxDate);
return d;

这是如何做到这一点的任何指针?

Any pointers on how to do this?

感谢

推荐答案

该getDatePicker()方法是在API级别可用11

The getDatePicker() method is available in API Level 11.

这篇关于在Android DatePickerDialog最大日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆