Android DatePickerDialog 怪异的 TextView
Android DatePickerDialog weird TextView
我发现了一些奇怪的东西:
再来看看正常的DatePickerDialog
:
当我添加这条设置昨天最大日期的行时:
datePickerDialog.getDatePicker().setMaxDate(yesterdayCal.getTime().getTime());
看起来像这样:
你看出区别了吗?它在 DatePicker 上方添加了一个 TextView。我不知道为什么。
它看起来很奇怪,并且总是显示与所选日期相同的日期。我想删除它?一些想法?
完整代码:
DatePickerDialog datePickerDialog = new DatePickerDialog(this, R.style.DialogTheme, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Calendar pickedCal = Calendar.getInstance(Locale.getDefault());
pickedCal.set(year, monthOfYear, dayOfMonth);
setToMidnight(pickedCal);
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE dd.MM.yyyy", Locale.getDefault());
String pickedDate = dateFormat.format(pickedCal.getTime());
MyToast.showLong(LiveSelectActivity.this, getString(R.string.hinweis_nachtragen_gueltig, pickedDate));
startNachtragen(pickedCal.getTime());
}
}, currentCalendar.get(Calendar.YEAR), currentCalendar.get(Calendar.MONTH), currentCalendar.get(Calendar.DAY_OF_MONTH));
/*Setzt das maximale Auswahldatum auf gestern.*/
Calendar yesterdayCal = (Calendar) currentCalendar.clone();
yesterdayCal.add(Calendar.DATE, -1);
datePickerDialog.getDatePicker().setMaxDate(yesterdayCal.getTime().getTime());
datePickerDialog.show();
}
出于某种原因,通过此行设置最大日期会设置 DatePickerDialog
的标题
datePickerDialog.getDatePicker().setMaxDate(yesterdayCal.getTime().getTime());
要删除标题,请使用setTitle("")
datePickerDialog.getDatePicker().setMaxDate(yesterdayCal.getTime().getTime());
datePickerDialog.setTitle("");
datePickerDialog.show();
我发现了一些奇怪的东西:
再来看看正常的DatePickerDialog
:
当我添加这条设置昨天最大日期的行时:
datePickerDialog.getDatePicker().setMaxDate(yesterdayCal.getTime().getTime());
看起来像这样:
你看出区别了吗?它在 DatePicker 上方添加了一个 TextView。我不知道为什么。 它看起来很奇怪,并且总是显示与所选日期相同的日期。我想删除它?一些想法?
完整代码:
DatePickerDialog datePickerDialog = new DatePickerDialog(this, R.style.DialogTheme, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Calendar pickedCal = Calendar.getInstance(Locale.getDefault());
pickedCal.set(year, monthOfYear, dayOfMonth);
setToMidnight(pickedCal);
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE dd.MM.yyyy", Locale.getDefault());
String pickedDate = dateFormat.format(pickedCal.getTime());
MyToast.showLong(LiveSelectActivity.this, getString(R.string.hinweis_nachtragen_gueltig, pickedDate));
startNachtragen(pickedCal.getTime());
}
}, currentCalendar.get(Calendar.YEAR), currentCalendar.get(Calendar.MONTH), currentCalendar.get(Calendar.DAY_OF_MONTH));
/*Setzt das maximale Auswahldatum auf gestern.*/
Calendar yesterdayCal = (Calendar) currentCalendar.clone();
yesterdayCal.add(Calendar.DATE, -1);
datePickerDialog.getDatePicker().setMaxDate(yesterdayCal.getTime().getTime());
datePickerDialog.show();
}
出于某种原因,通过此行设置最大日期会设置 DatePickerDialog
datePickerDialog.getDatePicker().setMaxDate(yesterdayCal.getTime().getTime());
要删除标题,请使用setTitle("")
datePickerDialog.getDatePicker().setMaxDate(yesterdayCal.getTime().getTime());
datePickerDialog.setTitle("");
datePickerDialog.show();