XxGoliathusxX XxGoliathusxX - 1 month ago 8
Android Question

Android DatePickerDialog weird TextView

I've discovered something strange:

Let's take a look at the normal

DatePickerDialog
:

Without

When I add this line which sets the maximum date on yesterday:

datePickerDialog.getDatePicker().setMaxDate(yesterdayCal.getTime().getTime());


It looks like this:

with

You see the difference? It adds a TextView above the DatePicker. I don't know why.
It looks weird and always shows the same date as selected. I want to remove it? Some ideas?

Full code:

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();

}

Answer

For some reason setting the max date through this line sets the title of the DatePickerDialog

datePickerDialog.getDatePicker().setMaxDate(yesterdayCal.getTime().getTime());

In order to remove the title, use setTitle("")

datePickerDialog.getDatePicker().setMaxDate(yesterdayCal.getTime().getTime());
datePickerDialog.setTitle("");
datePickerDialog.show();