Why does the datepicker add a calendar in my view?

我与影子孤独终老i 提交于 2019-12-03 09:35:23

Add this line to your date picker xml

android:calendarViewShown="false"

This will remove the Calendar.

All you need add under the:

 <datepicker>

method, just add:

 android:calendarViewShown="false"

This will remove the calendar, but keep the scroller.

Hope this helps

I had the same problem. I haven't created any xml file. So I fixed by changing the value of calendarviewshow in Activity. Hope it will help somebody.

We can hide the calendar view in DatePicker using two methods.

1 In Layout(XML file)(Thanks to @coconess)

<DatePicker
    android:id="@+id/datepickerv1"
    android:calendarViewShown="false">

2 In Activity(Java file)

Note: If you are not using "calendarViewShow" in xml, follow this step.
DatePicker dp=(DatePicker)findViewById(R.id.datepickerv1);
dp.setCalendarViewShown(false);

Change your datepicker from xml as follows :

<DatePicker
android:id="@+id/dpDateAchatProduit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:calendarViewShown="false" />

Add

android:datePickerMode="spinner"

instead of

android:calenderViewShown="false"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!