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 8013727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:42:40+00:00 2026-06-04T19:42:40+00:00

This question describes how to do it using a DatePicker widget, but I haven’t

  • 0

This question describes how to do it using a DatePicker widget, but I haven’t got anything like that.

I have these:

@Override
protected Dialog onCreateDialog(int id)
{

    switch (id)
    {
    case DATE_DIALOG_ID:
        return new DatePickerDialog(this, mDateSetListener, mYear1, mMonth1, mDay1);
    case DATE_DIALOG_ID_2:
        return new DatePickerDialog(this, mDateSetListener2, mYear2, mMonth2, mDay2);
    case DATE_DIALOG_ID_3:
        return new DatePickerDialog(this, mDateSetListener3, mYear3, mMonth3, mDay3);
    }
    return null;
}


protected void onPrepareDialog(int id, Dialog dialog)
{

    switch (id)
    {
    case DATE_DIALOG_ID:
        ((DatePickerDialog) dialog).updateDate(mYear1, mMonth1, mDay1);
        break;
    case DATE_DIALOG_ID_2:
        ((DatePickerDialog) dialog).updateDate(mYear2, mMonth2, mDay2);
        break;
    case DATE_DIALOG_ID_3:
        ((DatePickerDialog) dialog).updateDate(mYear3, mMonth3, mDay3);
        break;
    }
}

and then three DatePickerDialog.OnDateSetListener() s

There is no setMax() or setMin() on these DatePickerDialogs.

Thanks in advance.

  • 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-06-04T19:42:42+00:00Added an answer on June 4, 2026 at 7:42 pm

    Just implement your own DatePickerDialog, that changes the date back to a allowed date if the user tries to change it below the minimum date.

    A stripped version of the one I am using is:

    public class MyDatePickerDialog extends DatePickerDialog{
    
    private Date maxDate;
    private Date minDate;
    
    public MyDatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) {
        super(context, callBack, year, monthOfYear, dayOfMonth);        
        init(year, monthOfYear, dayOfMonth);
    }
    
    public MyDatePickerDialog(Context context, int theme, OnDateSetListener callBack, int year, int monthOfYear,    int dayOfMonth) {
        super(context, theme, callBack, year, monthOfYear, dayOfMonth);
        init(year, monthOfYear, dayOfMonth);
    }
    
    private void init(int year, int monthOfYear, int dayOfMonth){
        Calendar cal = Calendar.getInstance();
    
        cal.set(1970, Calendar.JANUARY, 1);
        minDate = cal.getTime();
    
        cal.set(3000, Calendar.JANUARY, 1);
        maxDate = cal.getTime();
    
        cal.set(year, monthOfYear, dayOfMonth);
    }
    
    public void onDateChanged (final DatePicker view, int year, int month, int day){
        Calendar cal = Calendar.getInstance();
        cal.set(year, month, day);
        Date currentDate = cal.getTime();
    
        final Calendar resetCal = cal; 
        if(!minDate.before(currentDate) ){
            cal.setTime(minDate);
            view.updateDate(resetCal.get(Calendar.YEAR), resetCal.get(Calendar.MONTH), resetCal.get(Calendar.DAY_OF_MONTH));
    
        }else if(maxDate.before(currentDate)){
            cal.setTime(maxDate);
            view.updateDate(resetCal.get(Calendar.YEAR), resetCal.get(Calendar.MONTH), resetCal.get(Calendar.DAY_OF_MONTH));
        }       
    }
    
    public void setMaxDate(Date date){
        this.maxDate = date;
    }
    
    public void setMinDate(Date date){
        this.minDate = date;
    }   
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a feeling I may already know the answer to this question, but
This question describes how auto indent is ignored with empty lines, using his/her example:
I am using xmllint --schema option to validate my XML that looks like this
I am using the following code that I originally found from this question: Prevent
Asking this question here because in CakePHP google group got no answer.I have the
I am using the method described in this question to load intial users for
I'm using the method described by Josh in this question to add a toolbar
I am using the code as described in this question. However get following error
This question might be naive as I'm new to ColdFusion programming. I have a
The question is a bit hypothetical. Let's say I have an application that draws

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.