Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6792011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:54:59+00:00 2026-05-26T17:54:59+00:00

I am trying to implement date picker on a button in android. But as

  • 0

I am trying to implement date picker on a button in android. But as soon as i click on the button error pops up. But time picker runs fine. Here’s the code:

mPickDate.setOnClickListener(new View.OnClickListener() {       //Assigning onClickListener to Date Button                                                                  
        public void onClick(View v) {
            showDialog(DATE_DIALOG_ID);
            }    
    });

    pickTime.setOnClickListener(new View.OnClickListener() {        //Assigning onClickListener to Time Button

        @Override
        public void onClick(View v) {
            showDialog(TIME_DIALOG_ID);

        }
    });
    }

    @Override
    protected Dialog onCreateDialog(int id) {                       //Overriding onCreateDialog()
        switch (id) {
        case DATE_DIALOG_ID:
            return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay);
        case TIME_DIALOG_ID:
            return new TimePickerDialog(this,mTimeSetListener,mHour,mMin,true);

        }
        return null;
    }

    TimePickerDialog.OnTimeSetListener mTimeSetListener = new TimePickerDialog.OnTimeSetListener() {        //Defining the TimePickerDialog reference variable

        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            mHour=hourOfDay;
            mMin= minute;
            updateTime();
        }
    };

    DatePickerDialog.OnDateSetListener mDateSetListener =                       //Defining the DatePickerDialog reference variable
        new DatePickerDialog.OnDateSetListener() {

            public void onDateSet(DatePicker view, int year, 
                                  int monthOfYear, int dayOfMonth) {
                mYear = year;
                mMonth = monthOfYear;
                mDay = dayOfMonth;
                updateDisplay();
            }
        };        

Here’s the logcat:

10-13 16:41:46.878: ERROR/AndroidRuntime(761): FATAL EXCEPTION: main
10-13 16:41:46.878: ERROR/AndroidRuntime(761): java.lang.IllegalArgumentException: current should be >= start and <= end
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.widget.NumberPicker.setCurrent(NumberPicker.java:288)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.widget.DatePicker.updateDaySpinner(DatePicker.java:370)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.widget.DatePicker.updateSpinners(DatePicker.java:356)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.widget.DatePicker.init(DatePicker.java:352)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.app.DatePickerDialog.<init>(DatePickerDialog.java:127)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.app.DatePickerDialog.<init>(DatePickerDialog.java:86)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at acb.xiynove.OfflineScreen_ACBActivity.onCreateDialog(OfflineScreen_ACBActivity.java:74)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.app.Activity.onCreateDialog(Activity.java:2482)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.app.Activity.createDialog(Activity.java:882)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.app.Activity.showDialog(Activity.java:2557)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.app.Activity.showDialog(Activity.java:2524)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at acb.xiynove.OfflineScreen_ACBActivity$3.onClick(OfflineScreen_ACBActivity.java:56)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.view.View.performClick(View.java:2485)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.view.View$PerformClick.run(View.java:9080)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.os.Handler.handleCallback(Handler.java:587)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.os.Looper.loop(Looper.java:123)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at android.app.ActivityThread.main(ActivityThread.java:3683)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at java.lang.reflect.Method.invokeNative(Native Method)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at java.lang.reflect.Method.invoke(Method.java:507)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-13 16:41:46.878: ERROR/AndroidRuntime(761):     at dalvik.system.NativeStart.main(Native Method)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:55:00+00:00Added an answer on May 26, 2026 at 5:55 pm

    I’ve got the same problem but I found solution. You should initialize mYear,mMonth,mDay:

    //Init this variables as you wish eg.:
    private int mYear = 2010;
    private int mMonth = 11;
    private int mDay =1;
    @Override
    protected Dialog onCreateDialog(int id) {                       //Overriding onCreateDialog()
        switch (id) {
        case DATE_DIALOG_ID:
            return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay);
        case TIME_DIALOG_ID:
            return new TimePickerDialog(this,mTimeSetListener,mHour,mMin,true);
    
        }
        return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement both the date picker and time picker. However, when
I'm trying to implement without success a Date iterator with Joda time. I need
I am trying to implement the the date picker by clicking on textfield. I
im trying to implement a custom error page, what i want to be able
I am trying to implement the Jquery datepicker using a google hosted theme. But
I'm trying to implement a Search-Function using c++ and libpqxx. But I've got the
I'm trying to follow the tutorial found here to implement a service layer in
I am trying to implement an MVC3 DatePicker but having trouble. I have the
I am currently trying to implement the wonderful jQuery plugin 'week calendar' ( here
I'm trying to implement Writable class, but i have no idea on how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.