Android DatePickerDialog and TimePickerDialog not rendering preview -
i'm creating form consists of edittexts launch datepickerdialogs , timepickerdialogs.
here sections of code:
datepickerdialog
datepickerdialog datepicker = new datepickerdialog(context, new datepickerdialog.ondatesetlistener() { @override public void ondateset(android.widget.datepicker view, int chosenyear, int chosenmonth, int chosendate) { year = chosenyear; month = chosenmonth; date = chosendate; set(year, month, date); } }, year, month, date); datepicker.settitle("select date"); datepicker.show();
timepickerdialog
timepickerdialog timepicker = new timepickerdialog(context, new timepickerdialog.ontimesetlistener() { @override public void ontimeset(android.widget.timepicker view, int chosenhour, int chosenminute) { hour = chosenhour; minute = chosenminute; set(hour, minute); } }, hour, minute, false); timepicker.settitle("select time"); timepicker.show();
everything works should such launching dialogs , setting date properly. there's 1 problem. previews not rendered. don't know why. hope help. thanks.
here screenshots: notice white backgrounds.
in styles.xml add 2 new styles:
<style name="datepicker" parent="theme.appcompat.light.dialog"> <item name="coloraccent">@color/your_color</item> </style> <style name="timepicker" parent="theme.appcompat.light.dialog"> <item name="coloraccent">@color/your_color</item> </style>
then refer these styles in custom theme followed:
<item name="android:datepickerdialogtheme" tools:targetapi="21">@style/datepicker</item> <item name="android:timepickerdialogtheme" tools:targetapi="21">@style/timepicker</item>
Comments
Post a Comment