currently, datepicker dialogue looks this. using theme_holo_light_dialog
theme.
but achieve following, title , buttons using appcompat dialog style (given understanding, material theme), yet center spinners still maintaining non-material style (the selections).
solved issue!
instead of going through trouble of styling dialog box, used alertdialog
, inflated layout containing datepicker
.
datepicker.xml
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <datepicker android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/daily_datepicker" android:layout_centerinparent="true" android:calendarviewshown="false" android:datepickermode="spinner"/> </relativelayout>
and in code-behind...
public alertdialog.builder displaydailyoverviewdialog() { alertdialog.builder dialog = new alertdialog.builder(getactivity()); layoutinflater inflater = getactivity().getlayoutinflater(); view dialogview = inflater.inflate(r.layout.datepicker, null); dialog.settitle("set daily overview"); dialog.setview(dialogview); datepicker dp = (datepicker) dialogview.findviewbyid(r.id.daily_datepicker); calendar calendar = calendar.getinstance(); calendar.set(calendar.day_of_month, 1); dp.setmindate(calendar.gettimeinmillis()); dp.setmaxdate(new date().gettime()); dp.findviewbyid(resources.getsystem().getidentifier("month", "id", "android")).setvisibility(view.gone); dp.findviewbyid(resources.getsystem().getidentifier("year", "id", "android")).setvisibility(view.gone); dialog.setpositivebutton(android.r.string.yes, new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { } }) .setnegativebutton(android.r.string.no, new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { } }); dialog.create(); return dialog; }
Comments
Post a Comment