private Dialog CreateDialog() {
// TODO Auto-generated method stub
MyDatePickerDialog dialog = null;
c = Calendar.getInstance();
dialog = new MyDatePickerDialog(this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker arg0, int arg1, int arg2,
int arg3) {
startActivity(intent);
// finish();
}
}, c.get(Calendar.YEAR), // 传入年份
c.get(Calendar.MONTH), // 传入月份
c.get(Calendar.DAY_OF_MONTH) // 传入天数
);
dialog.setCancelable(true);
Locale.CHINA);
Date myDate1 = null;
try {
myDate1 = dateFormat1.parse("2000-01-01");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return dialog;
}
//自定义时间类。。。。。。。。。。
private class MyDatePickerDialog extends DatePickerDialog {
public MyDatePickerDialog(Context context, OnDateSetListener callBack,
int year, int monthOfYear, int dayOfMonth) {
super(context, DatePickerDialog.THEME_HOLO_LIGHT,
callBack, year, monthOfYear, dayOfMonth);
// TODO Auto-generated constructor stub
// TODO Auto-generated method stub
MyDatePickerDialog dialog = null;
c = Calendar.getInstance();
dialog = new MyDatePickerDialog(this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
//选择时间后,跳入另外一个activity
intent = new Intent(context, MapActivity.class);startActivity(intent);
// finish();
}
}, c.get(Calendar.YEAR), // 传入年份
c.get(Calendar.MONTH), // 传入月份
c.get(Calendar.DAY_OF_MONTH) // 传入天数
);
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
//设置最大时间
dialog.getDatePicker().setMaxDate(new Date().getTime());
//设定时间样式
DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd",Locale.CHINA);
Date myDate1 = null;
try {
myDate1 = dateFormat1.parse("2000-01-01");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//设置最小时间
dialog.getDatePicker().setMinDate(myDate1.getTime());return dialog;
}
//自定义时间类。。。。。。。。。。
private class MyDatePickerDialog extends DatePickerDialog {
public MyDatePickerDialog(Context context, OnDateSetListener callBack,
int year, int monthOfYear, int dayOfMonth) {
super(context, DatePickerDialog.THEME_HOLO_LIGHT,
callBack, year, monthOfYear, dayOfMonth);
// TODO Auto-generated constructor stub
}
//在需要的地方可以调用CreateDialog().show()方法来显示时间对话框