A material Date Range Picker based on wdullaers MaterialDateTimePicker

Overview

Android Arsenal

Download

Maven Central

Material Date and Time Picker with Range Selection

Credits to the original amazing material date picker library by wdullaer - https://github.com/wdullaer/MaterialDateTimePicker

Adding to your project

Add the jcenter repository information in your build.gradle file like this

repositories {
  jcenter()
}


dependencies {
  implementation 'com.borax12.materialdaterangepicker:library:2.0'
}

Beginning Version 2.0 now also available on Maven Central

Date Selection

FROM TO

Time Selection

FROM TO

Support for Android 4.0 and up.

From the original library documentation -

You may also add the library as an Android Library to your project. All the library files live in library.

Using the Pickers

  1. Implement an OnDateSetListener or OnTimeSetListener
  2. Create a ``DatePickerDialog` using the supplied factory

Implement an OnDateSetListener

In order to receive the date set in the picker, you will need to implement the OnDateSetListener interfaces. Typically this will be the Activity or Fragment that creates the Pickers.

or

Implement an OnTimeSetListener

In order to receive the time set in the picker, you will need to implement the OnTimeSetListener interfaces. Typically this will be the Activity or Fragment that creates the Pickers.

//new onDateSet
@Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth,int yearEnd, int monthOfYearEnd, int dayOfMonthEnd) {

}

@Override
public void onTimeSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth,int yearEnd, int monthOfYearEnd, int dayOfMonthEnd) {
        String hourString = hourOfDay < 10 ? "0"+hourOfDay : ""+hourOfDay;
        String minuteString = minute < 10 ? "0"+minute : ""+minute;
        String hourStringEnd = hourOfDayEnd < 10 ? "0"+hourOfDayEnd : ""+hourOfDayEnd;
        String minuteStringEnd = minuteEnd < 10 ? "0"+minuteEnd : ""+minuteEnd;
        String time = "You picked the following time: From - "+hourString+"h"+minuteString+" To - "+hourStringEnd+"h"+minuteStringEnd;

        timeTextView.setText(time);

}

Create a DatePickerDialog` using the supplied factory

You will need to create a new instance of DatePickerDialog using the static newInstance() method, supplying proper default values and a callback. Once the dialogs are configured, you can call show().

Calendar now = Calendar.getInstance();
DatePickerDialog dpd = DatePickerDialog.newInstance(
  MainActivity.this,
  now.get(Calendar.YEAR),
  now.get(Calendar.MONTH),
  now.get(Calendar.DAY_OF_MONTH)
);
dpd.show(getFragmentManager(), "Datepickerdialog");

Create a TimePickerDialog` using the supplied factory

You will need to create a new instance of TimePickerDialog using the static newInstance() method, supplying proper default values and a callback. Once the dialogs are configured, you can call show().

Calendar now = Calendar.getInstance();
TimePickerDialog tpd = TimePickerDialog.newInstance(
                        MainActivity.this,
                        now.get(Calendar.HOUR_OF_DAY),
                        now.get(Calendar.MINUTE),
                        false
                );
tpd.show(getFragmentManager(), "Timepickerdialog");

For other documentation regarding theming , handling orientation changes , and callbacks - check out the original documentation - https://github.com/wdullaer/MaterialDateTimePicker

Comments
  • Can't select end date month different from start date month

    Can't select end date month different from start date month

    Hello I found new bug when I select start date month and then want to select end date month which is different from selected start date month , it selects but it returns you in same month which was selected on start date.

    opened by figus1909 23
  • Crash when the library is used along with wdullaer/MaterialDateTimePicker

    Crash when the library is used along with wdullaer/MaterialDateTimePicker

    Fatal Exception: java.lang.ClassCastException: com.wdullaer.materialdatetimepicker.date.AccessibleDateAnimator cannot be cast to com.borax12.materialdaterangepicker.date.AccessibleDateAnimator
           at com.borax12.materialdaterangepicker.date.DatePickerDialog.onCreateView(DatePickerDialog.java:371)
           at android.app.Fragment.performCreateView(Fragment.java:2114)
           at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:904)
           at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
           at android.app.BackStackRecord.run(BackStackRecord.java:834)
           at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1469)
           at android.app.FragmentManagerImpl$1.run(FragmentManager.java:452)
           at android.os.Handler.handleCallback(Handler.java:739)
           at android.os.Handler.dispatchMessage(Handler.java:95)
           at android.os.Looper.loop(Looper.java:145)
           at android.app.ActivityThread.main(ActivityThread.java:6946)
           at java.lang.reflect.Method.invoke(Method.java)
           at java.lang.reflect.Method.invoke(Method.java:372)
           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
    
    opened by ragunathjawahar 14
  • Instantiate DatePickerDialog from Fragment

    Instantiate DatePickerDialog from Fragment

    Am using the v4 support version of the android Fragment and am unable to instate the date picker with version 1.7 of the library. All attempts to set the listener and the fragmentManager fail. The parameters are not being accepted. The listener is implemented on the Fragment and the fragment is hosted in an activity that extends AppCompatActivity.

    opened by larrytech7 12
  • Change HEADER[

    Change HEADER["FROM" "TO"]

    I need to change the "FROM" and "TO" strings on top of DatePicker, such that I am using multilanguage app. Which string I have to define in strings.xml file in order to change this headers.

    opened by figus1909 8
  • Date picker To jump back after click on day

    Date picker To jump back after click on day

    Date picker on To card jump back on current month after select some day in onother month/year than is current.

    • select some day in FROM card
    • swipe to next month
    • click on some day
    • ! calendar jump back on actual month selected in FROM card.

    The behavior on FROM and TO cards is different. Tested on Android 5.0

    opened by mtrakal 8
  • NoSuchFieldError

    NoSuchFieldError

    i implemented the sample code, but got the following error:

    java.lang.NoSuchFieldError: com.borax12.materialdaterangepicker.R$id.tabHost at com.borax12.materialdaterangepicker.time.TimePickerDialog.onCreateView(TimePickerDialog.java:281)

    opened by MeinLieberScholli 7
  • How to I change the text colour of the Tabs - FROM and TO?

    How to I change the text colour of the Tabs - FROM and TO?

    HI! First of all, thank you for the awesome library. It is very easy to use. I just have one question. How to change the colour of the two tabs at the top of the picker (TimePickerDialog more specificly). Currently, it looks like that:

    device-2017-02-27-123444

    Thank you in advance!

    opened by georgikoemdzhiev 5
  • It doesn't work with original wdullaer/MaterialDateTimePicker

    It doesn't work with original wdullaer/MaterialDateTimePicker

    If I want to use this library (for data ranges), and original library https://github.com/wdullaer/MaterialDateTimePicker (for one date picker) - then my gradle didn't sync, because of some ids conflicts:

    /myApp/app/build/intermediates/exploded-aar/com.wdullaer/materialdatetimepicker/3.0.0/res/layout-land/mdtp_time_header_label.xml
    Error:(72, 31) No resource found that matches the given name (at 'layout_above' with value '@id/seconds_space').
    Warning:string 'mdtp_sans_serif' has no default translation.
    /myApp/app/build/intermediates/res/merged/debug/layout-land/mdtp_time_header_label.xml
    Error:(72, 31) No resource found that matches the given name (at 'layout_above' with value '@id/seconds_space').
    Error:Execution failed for task ':app:processDebugResources'.
    > com.android.ide.common.process.ProcessException: Failed to execute aapt
    
    opened by Kamil-Kaminski 5
  • Gradle Error:Could not find com.borax12.materialdaterangepicker:library:1.8.

    Gradle Error:Could not find com.borax12.materialdaterangepicker:library:1.8.

    Gradle Error:Could not find com.borax12.materialdaterangepicker:library:1.8.

    http://gradleplease.appspot.com/#borax12 https://bintray.com/search?query=borax12

    Anyone knows how to include this library?

    opened by leoliudeprecated 5
  • Adding singledatepicker

    Adding singledatepicker

    Hi I would like to add a feature wherein we can use this library to somewhat disable the two tabs (From,To). So we can use it for just getting a single date. However I'm new to library cloning so can anyone help me with this? I know how to clone but my idea for adding this as a module is limited. Thanks

    opened by christianCallelero 4
  • Only one option, instead of From & To

    Only one option, instead of From & To

    Is there a way to only enable one option dialog, no two (From & To). I know the whole point of this library is that it is a range picker, but it's probably worth asking.

    I need a range picker for date, but only single picker for time. My options are to use android picker for time, but I want it to look the same for older versions of Android.

    opened by ghost 4
  • Update library for darkMode

    Update library for darkMode

    Hey. I would really appreciate if you would update the library with support for the dark theme. The color of the year is always black and it looks bad on a dark topic. 2020-02-11_10-53-52

    opened by aleksandrmozgovoi 0
  • setAccentColor is not working with Time Picker

    setAccentColor is not working with Time Picker

    When you set Accent Color on the Time Picker dialog, it is just changing the OK button and the selection circle but not working on Cancel button, Background of display of the selected time. Can you please fix it or put set methods so that we can set based on our requirements?

    Current code from the lib. It should have cancel button and other views as well. if (mAccentColor != -1) { mTimePicker.setAccentColor(mAccentColor); mTimePickerEnd.setAccentColor(mAccentColor); mOkButton.setTextColor(mAccentColor); }

    Btw it's working fine with Date Picker.

    opened by yasirtahir 1
Releases(1.9)
Owner
Supratim
HCI Researcher at School of Interactive Arts and Technology.
Supratim
Android widget for selecting a range of values.

MaterialRangeBar MaterialRangeBar is a fork from https://github.com/edmodo/range-bar that adds some basic material styling, as well as start and end v

null 1.7k Dec 30, 2022
A color picker seekbar for android.

ColorSeekBar A color picker seekbar for android. Download Use Gradle compile 'com.divyanshu.colorseekbar:colorseekbar:1.0.2' or Maven <dependency>

Divyanshu Bhargava 129 Nov 29, 2022
A simple material-based support library to bring consistent SeekBars on Android 14 and above

SeekBarCompat A support library for the material design SeekBar in Android for API 14 and above. Screenshot On APIs 14 and above - Seekbars would look

Ahmed Rizwan 157 Dec 27, 2022
A material Date Range Picker based on wdullaers MaterialDateTimePicker

Material Date and Time Picker with Range Selection Credits to the original amazing material date picker library by wdullaer - https://github.com/wdull

Supratim 1.3k Dec 14, 2022
A material Date Range Picker based on wdullaers MaterialDateTimePicker

Material Date and Time Picker with Range Selection Credits to the original amazing material date picker library by wdullaer - https://github.com/wdull

Supratim 1.3k Dec 14, 2022
A date time range picker for android written in Kotlin

DateTimeRangePicker A date time range picker for android Usage Firstly, grab latest release of the library via JitPack. And note that, it utilizes Jod

SkedGo 501 Dec 31, 2022
Nepali Date Picker library in Jetpack compose for android with Date conversion from BS to AD and vice-versa

Nepali Date picker Converter - Re in Compose This is a re-work of Nepali Date Picker Converter in jetpack compose and kotlin. English Locale Nepali Lo

Kiran Gyawali 4 Dec 23, 2022
Material (Gregorian - Hijri) Date & Time Picker

Hijri Date Picker (UmAlQuraCalendar) This library offers a hijri (Islamic Calendar) Date Picker designed on Google's Material Design Principals For Pi

Abdullah Alhazmy 130 Dec 27, 2022
Material (Gregorian - Hijri) Date & Time Picker

Hijri Date Picker (UmAlQuraCalendar) This library offers a hijri (Islamic Calendar) Date Picker designed on Google's Material Design Principals For Pi

Abdullah Alhazmy 130 Dec 27, 2022
Android time range picker

TimeRangePicker TimeRangePicker is a library which can be used to select a time range. WARNING Requires android-support-v4 Description This library pr

Titto Jose 422 Nov 10, 2022
A customizable, easy-to-use, and functional circular time range picker library for Android

A customizable, easy-to-use, and functional circular time range picker library for Android. Use this library to mimic Apple's iOS or Samsung's bedtime picker.

Joery Droppers 251 Dec 30, 2022
Compose Date Picker - Select month and year

Android DatePicker with month and year build with Compose UI

Doğuş Teknoloji 47 Dec 15, 2022
Time-DatePicker - A Simple Time Date Picker With Kotlin

Time-DatePicker Time.DatePicker.mp4

Faysal Hossain 0 Jan 19, 2022
Add Wheel Date - Time Picker in Android Jetpack Compose.

WheelPickerCompose Add Wheel Date - Time Picker in Android Jetpack Compose. Usage Picker Usage WheelDateTimePicker { snappedDateTime -> } WheelDatePic

Emir Demirli 81 Dec 30, 2022
A beautiful material calendar with endless scroll, range selection and a lot more!

CrunchyCalendar A light, powerful and easy to use Calendar Widget with a number out of the box features: Infinite vertical scrolling in both direction

CleverPumpkin 483 Dec 25, 2022
Pix is a Whatsapp image picker replica. with this, you can integrate an image picker just like WhatsApp.

Pix (WhatsApp Style Image and Video Picker) Pix is a WhatsApp image picker replica. with this you can integrate a image picker just like WhatsApp. Upc

Akshay sharma 742 Jan 4, 2023
Android Country Picker is a Kotlin-first, flexible and powerful Android library that allows to integrate Country Picker with just a few lines.

1. Add dependency dependencies { implementation 'com.hbb20:android-country-picker:X.Y.Z' } For latest version, 2. Decide your use-case

Harsh B. Bhakta 65 Dec 6, 2022
Facebook-Styled-Image-Picker - Facebook Styled Image Picker

Facebook-Styled-Image-Picker Facebook Styled Gallery Files picker. One or multip

Hashim Tahir 11 Sep 27, 2022
Picker-kt - Media picker library powered by Jetpack Compose

ANDROID LIBRARY PickerKT A media picker library for Android apps powered by Jetp

Tanawin Wichit 20 Jan 2, 2023
A material-styled android view that provisions picking of a date, time & recurrence option, all from a single user-interface.

SublimePicker A customizable view that provisions picking of a date, time & recurrence option, all from a single user-interface. You can also view 'Su

Vikram 2.3k Jan 4, 2023