final Calendar objTime = Calendar.getInstance();
int iYear = objTime.get(Calendar.YEAR);
int iMonth = objTime.get(Calendar.MONTH);
int iDay = objTime.get(Calendar.DAY_OF_MONTH);
DatePickerDialog datePickerDialog = new DatePickerDialog(QueryDateActivity.this, DatePickerListener, iYear, iMonth, iDay);
datePickerDialog.setCanceledOnTouchOutside(true);
datePickerDialog.show();
我已经设置为true了 可是还是不消失为什么?
/**下面是原代码
*/
final DatePickerDialog mDialog_start = new DatePickerDialog(this, null,
con_year_start, con_month_start, con_day_start);
//手动设置按钮
mDialog_start.setButton(DialogInterface.BUTTON_POSITIVE, "完成", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//通过mDialog.getDatePicker()获得dialog上的DatePicker组件,然后可以获取日期信息
DatePicker datePicker = mDialog_start.getDatePicker();
int year = datePicker.getYear();
int month = datePicker.getMonth();
int day = datePicker.getDayOfMonth();
tv_start.setText(year+"/"+months[month]+"/"+day);
con_year_start = year;
con_month_start = month;
con_day_start = day;
}
});
//取消按钮,如果不需要直接不设置即可
mDialog_start.setButton(DialogInterface.BUTTON_NEGATIVE, "取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mDialog_start.dismiss();
}
});
mDialog_start.setTitle("请选择开始时间");
mDialog_start.setCanceledOnTouchOutside(true);
mDialog_start.show();