How can I customize a date and time chooser - android

I wanna make a custom fragment to choose date ana time like the one on justPark app. Can someone help me with a turo or link to do it.
Thank you

You can use Android's Calendar API to create your very own implementation with any user interface you like. But making a fully proportionate calendar type view date picker is a lengthy task and would take some time.Since the android's default date picker is flexible enough to adapt your app's theme you may not find custom calendar implementations commonly but sure you can checkout 3rd party libraries.
Here's one for example caldroid
its a custom calendar implementation in a fragment.
Hope this helps.

Related

Is it possible to switch the format of date picker header?

I am trying to change the header on material design date picker as you select a date to a different format than default. Current default is Month , year : ex: june 22, 2021, but I want it such that its Mon, June 22. It's shown on material design document as the first design, but there's no indication of how to go about changing this format?
Any ideas?
material designs : https://material.io/components/date-pickers
what I want to achieve is this :
Unfortunately, you can NOT change Date Format and Local of MaterialDatePicker.
Since MaterialDatePicker is very restricting, so as many other Material Design Components, I recommend you to use an alternate Date Picker Library such as MaterialDateTimePicker.
It basically fulfills all your needs:
Change date format: setLocale(Locale locale) ✅
Choose from multiple date UIs ✅
Very flexiable and easily customizlbe to fit your needs ✅
PS: There is one more popular alternative: android-betterpickers
Let me know if you have any other questions.
After looking into the source, and trying some things, I did find a solution. Unfortunately, it's not that simple to implement and I guess switching to MaterialDateTimePicker is still the best solution here.
The conversion from date to text for the header is done by the DateSelector via getSelectionDisplayString(Context context). See getHeaderText() inside of MaterialDatePicker here.
Sadly, MaterialDatePicker is final, so you can not simply create your own and override this method. But, with the given Builder, you can use MaterialDatePicker.Builder.customDatePicker(DateSelector selector) to place your own DateSelector (source).
Material uses their SingleDateSelector (source) for a simple date selection. But again, it's not possible to build upon this selector and write a custom getSelectionDisplayString method, because the class is restricted. Knowing this, it's needed to write your own DateSelector.
Building your own DateSelector is a bigger task on its own. It may be possible to copy from SingleDateSelector, but it's using some private classes and methods you need to copy, too.
To cut a long story short, I guess this is too much for "simply" changing the date format.

How to decorate or highlight some dates on Calendar VIew in android?

In my project, I am getting a response from server.In that response there will be some dates of current month.I want to show those dates with different text color, different background color on calendar view.I waat to differentiate those dates from other dates.
I read that in default Calendar view we can't do that.
I've searched for external libraries.
I found MCalendar library.But in that library the calendar view not suits me.
Can anyone give me solution for this or direct me to perfect library I am looking for?
Thanks in Advance
Hey after two days search I found this library.
The library name is Material Calenderview: https://github.com/prolificinteractive/material-calendarview.
We can add custom colors to a list dates by using adding Decorator to this calendar view. If you go there you can see the documentation for adding decorator a calendar view fir highlighting some dates.

Is there an option to change Date Picker form?

I implemented date picker in my project from here: https://developer.android.com/guide/topics/ui/controls/pickers
The problem is, this date picker is in the format of regular calendar, and it takes a long time to choose faraway dates. In my app this kind of action is going to be performed all the time.
So, my question is, is there a possibility to change this calendar-like form to something faster? For example like in the picture below.
Picture of date picker i would like to make
check that library: https://github.com/florent37/SingleDateAndTimePicker
I've used it some time ago and it did almost exactly what you're looking for ;)
If it doesn't fit your needs, you can look for more 'iOS style date pickers' for Android, for example in this SO post:
ios like date/time picker for android platform
Edit:
It seems that this picker is Holo Light style and is achievable with this piece of code:
DatePickerDialog datepickerdialog = new DatePickerDialog(getActivity(),
AlertDialog.THEME_HOLO_LIGHT,this,year,month,day);
But you need to check that on your own because they might be deprecated or not working with other themes.
Did you check this for Material Design?
Here is its documentation and code.
The DatePicker widget in Android has an attribute called android:datePickerMode that has a calendar option and a spinner option.
You can use the spinner option to get the appearance of the DatePicker you are after.

How to display calendar view in a single row in android

i don't know how to customize a calendar view to be the same as the picture for my application. Here is my example picture.
In the past, I had the same problem so I have created a Kotlin library which solves this problem. You can create a calendar with your custom UI and use selection features with few lines of code. You can find the repository here and here is an article about my sample app.
Additionally, there is a similar library for Java here.
Yes u can define a custom calender view like that. Here is my suggestion:
ListView/ReceyclerView
Calendar class
Easy way is make user pick month/year first, your list only display day.

Adding text in Calendar View

I was trying to add text in my calendar view, here is the example how i want it to be like
http://postimg.org/image/wf4gxz1dr/
My CalendarView is in Material Design CalendarView, here is the link of my calendarView
http://postimg.org/image/iid1z41z1/
Is it possible to add text in this material design or i have to do it with the basic calendarView like in 1st picture.?
Please tell me how can i mak it possible in these views.
Sorry i can't upload screenshots here.
Thanks in Advance
Last month I was able to implement a little calendar view using Caldroid https://github.com/roomorama/Caldroid.
It's flexible to use and it's not so hard to get a custom calendar view as implementing onDraw from the CalendarView.
Check the view I created (just by following the documentation). Just create your own cell layout and implement it:
And of course you can go beyond that.

Categories

Resources