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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:46:46+00:00 2026-06-10T23:46:46+00:00

By referring DateWidgets1.java in API demo, I tend to show date picker widget through

  • 0

By referring DateWidgets1.java in API demo, I tend to show date picker widget through the following way.

private void initDateTextView() {
    dateTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            showDialog(DATE_DIALOG_ID);                
        }            
    });
}

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DATE_DIALOG_ID:
       // set date picker as current date
       return new DatePickerDialog(this, datePickerListener, 
                     this.year, this.month, this.date);
    }
    return null;
}

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    switch (id) {
    case DATE_DIALOG_ID:
        ((DatePickerDialog)dialog).updateDate(this.year, this.month, this.date);
    }        
}

private static final int DATE_DIALOG_ID = 0;
private final DatePickerDialog.OnDateSetListener datePickerListener = new DatePickerDialog.OnDateSetListener() {
    // When dialog box is closed, below method will be called.
    public void onDateSet(DatePicker view, int selectedYear, int selectedMonth, int selectedDay) {
        Log.i("CHEOK", selectedYear + ", " + selectedMonth + ", " + selectedDay);
    }
};

However, I realize, onDateSet will always be called, with latest spinner selected date, regardless I am pressing dialog’s Done button, or pressing the phone’s soft back button.

I am only interested in getting the selected date, when user pressing Done button, but not back button.

Is there any way I can achieve so?

  • 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-10T23:46:48+00:00Added an answer on June 10, 2026 at 11:46 pm

    This seems to be a bug in the framework as discussed in this post (with a suggested workaround included).

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

Sidebar

Related Questions

When referring to internal private variables of Java POJOs that have getters/setters, I've used
Referring to the Configuration Manager under the Build menu, Is there a way to
Referring to What is the correct way to make a custom .NET Exception serializable?
Referring to the code below, is there a way to bind the test 2
Referring to this question, let's say we have the following scenario - A model
Referring to article Gotw 54 by HerbSutter, he explains about The Right Way To
Referring to the discussion performSelector where is explained that with the following line it
Referring to the following tutorial: ADO.NET Entity Framework Tutorial and Basics I am trying
Referring to, executing management commands from code , Is their a way to call
Referring to a slightly modified version of a jqGrid local editing demo by user

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.