How to create a Datepickerdialog pre Lollipop

Asked

Viewed 293 times

0

I’ve done everything and I couldn’t make a Datepickerdialog like this...

inserir a descrição da imagem aqui

for pre Lollipop versions. The code I’m using for now:

 DatePickerDialog dlg = new DatePickerDialog(ActivityAddAvaliacoes.this, new DatePickerDialog.OnDateSetListener() {
   @Override
   public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                            edtAddData.setText(dayOfMonth+"-"+monthOfYear+"-"+year);
                        }
                    }, year, month,day).show();

1 answer

1

How did I even answer that question: Link. This Datepicker is only for Android 5.0 and above, if you want to use it in older versions, you would have to manually port it, but fortunately, some people have already done it and you can use a ready-made library:

That one: Materialdatetimepicker allows you to use this Datepicker in versions 4.0 and higher, which would already reach a large portion of android phones.

Second option:

But, if you want something with a greater retro-compatibility, you can use this: android-betterpickers which allows you to use this Datepicker since API +9 which is Android 2.3:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.