我已经使用DatePickerDialog
来显示在Lollipop手机中工作的对话框,但是在android api 19中没有工作。在Android谷歌地图中也存在问题。地图在棒棒糖中可见,但在kitkat中不显示黑屏。
这里是代码:
final DatePickerDialog.OnDateSetListener datePickerListener=new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
date.setText(Integer.toString(dayOfMonth));
month.setText(Integer.toString(monthOfYear));
yearr.setText(Integer.toString(year));
//SimpleDateFormat simpleDateFormat=new SimpleDateFormat("dd-MMM-yyyy");
//chosenDate=simpleDateFormat.parse(Integer.toString(dayOfMonth)+"/"+Integer.toString(monthOfYear)+"/"+Integer.toString(year));
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH,monthOfYear);
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
chosenDate=cal.getTime();
for(int i=0;i<7;i++) {
Calendar c=Calendar.getInstance();
c.set(year,monthOfYear,dayOfMonth,10+i*2,0,0);
times[i]=new Date();
times[i] = c.getTime();
}
}
};
final TextView time = (TextView) findViewById(R.id.et_time);
datepicker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar cal = Calendar.getInstance();
time.setText("");
DatePickerDialog datePicker = new DatePickerDialog(BookingService.this, datePickerListener,
cal.get(Calendar.YEAR),
cal.get(Calendar.MONTH),
cal.get(Calendar.DAY_OF_MONTH));
datePicker.setCancelable(false);
datePicker.getDatePicker().setMinDate(new Date().getTime());
Dialog dialog=datePicker;
dialog.show();
}
});