您的位置:首页 > 其它

DatePickerDialog使用

2018-01-08 09:52 176 查看
调用

DatePickerDialog dialog = new DatePickerDialog(MainActivity.this, THEME_HOLO_LIGHT, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
//对选择的日期进行处理
}, int year,int month-1,int day);
dialog.show();

THEME_HOLO_LIGHT : theme设置 

请参考:http://blog.csdn.net/lckj686/article/details/19552793

修改显示的条目数:年、月、日的选择:

不显示日:
DatePicker dp = findDatePicker((ViewGroup) dialog1.getWindow()
.getDecorView());
if (dp != null) {

View view = ((ViewGroup) ((ViewGroup) dp.getChildAt(0))
.getChildAt(0)).getChildAt(2);
view.setVisibility(View.GONE);
}
private DatePicker findDatePicker(ViewGroup group) {
if (group != null) {
for (int i = 0, j = group.getChildCount(); i < j; i++) {
View child = group.getChildAt(i);
if (child instanceof DatePicker) {
return (DatePicker) child;
} else if (child instanceof ViewGroup) {
DatePicker result = findDatePicker((ViewGroup) child);
if (result != null)
return result;
}
}
}
return null;
}
请参考:http://blog.csdn.net/lzt623459815/article/details/8479991

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: