Code Monkey home page Code Monkey logo

eightfoldsdatepickerdialog's Introduction

EightFoldsDatePickerDialog

Using this you can easily set minimum and maximum dates to a datepicker dialog

Usage

Copy EightFoldsDatePickerDialog.java to your project

 
        val calendar = Calendar.getInstance()
        val datePickerDialog = EightFoldsDatePickerDialog(
            this,
            object : DatePickerDialog.OnDateSetListener {
                override fun onDateSet(view: DatePicker, year: Int, month: Int, dayOfMonth: Int) {

                    val date = "$dayOfMonth/$month/$year"
                   
                }
            },
            calendar.get(Calendar.YEAR),
            calendar.get(Calendar.MONTH),
            calendar.get(Calendar.DATE)
        )  

        datePickerDialog.setMinDate(2017,8,7); //arguments are   year , month , date (use for setting custom mix date)
        datePickerDialog.setMaxDate(2017,8,25);  //arguments are   year , month , date (use for setting custom max date)
       
     //   datePickerDialog.setTodayAsMinDate();   // sets today's date as min date
     //   datePickerDialog.setTodayAsMaxDate();    // sets today's date as max date

        datePickerDialog.show()

Result

eightfoldsdatepickerdialog's People

Contributors

redman1037 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

manhtuan1712

eightfoldsdatepickerdialog's Issues

Error when set first and min date as todau

When I set the first date and the min date as today

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.coffeeandcookies.construmat/com.coffeeandcookies.construmat.ui.Carro.CalendarioActivity}: java.lang.IllegalArgumentException: fromDate: Tue Sep 26 16:31:22 GMT-03:00 2017 does not precede toDate: Tue Sep 26 16:31:22 GMT-03:00 2017`

EightFoldsDatePickerDialog datePickerDialog=new EightFoldsDatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
            @Override
            public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                Toast.makeText(CalendarioActivity.this, "Year "+year+" month "+month+" day "+dayOfMonth, Toast.LENGTH_SHORT).show();
            }
        },calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH));   

datePickerDialog.setTodayAsMinDate();   // sets today's date as min date
datePickerDialog.show();

setMinDate not working

If I code this

datePickerDialog.setMinDate(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH)+1);

device-2017-09-26-164358

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.