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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:39:10+00:00 2026-06-11T04:39:10+00:00

I am using a DatePickerDialog to prompt the user for a date. It works

  • 0

I am using a DatePickerDialog to prompt the user for a date. It works fine in the simulator and on my Samsung Galaxy Nexus, but onDateSet does not get called on my Samsung Galaxy Tab 2.

I noticed, that the dialog is bigger and shows a calendar besides the normal spin view. Can that be the problem?

Here is some code:

import java.util.Calendar;
import java.util.Date;

import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.widget.DatePicker;

import com.cbit.gtbetapp.R;
import com.cbit.gtbetapp.gui.racedata.MeetingDataActivity;
import com.cbit.gtbetapp.gui.racedata.MeetingListFragment;
import com.cbit.gtbetapp.logic.Utility;

public class DatePickerFragment extends DialogFragment implements
        DatePickerDialog.OnDateSetListener {

    protected Date date = null;

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        // Use the current date as the default date in the picker
        final Calendar c = Utility.getToday();
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);
        date = c.getTime();

        // Create a new instance of DatePickerDialog and return it
        DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day) {
            @Override
            public void onDateChanged(DatePicker view, int year, int month, int day) {
                super.onDateChanged(view, year, month, day);
                setTitle(getString(R.string.date_picker_title));
            }
        };
        dialog.setTitle(getString(R.string.date_picker_title));

        dialog.setButton(DatePickerDialog.BUTTON_POSITIVE,
                getString(android.R.string.ok), new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();

                        Intent intent = new Intent(getActivity(), MeetingDataActivity.class);
                        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        intent.putExtra(MeetingListFragment.EXTRA_DATE, date.getTime());
                        startActivity(intent);
                    }
                });
        dialog.setButton(DatePickerDialog.BUTTON_NEGATIVE,
                getString(R.string.button_cancel),
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
        return dialog;
    }

    public void onDateSet(DatePicker view, int year, int month, int day) {
        Calendar c = Calendar.getInstance();
        c.clear();
        c.set(Calendar.YEAR, year);
        c.set(Calendar.MONTH, month);
        c.set(Calendar.DAY_OF_MONTH, day);
        date = c.getTime();
    }
}

What could cause this? A bug in the tablet? Am I missing something? Can anyone think of a workaround?

Thanks a lot!

  • 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-11T04:39:11+00:00Added an answer on June 11, 2026 at 4:39 am

    I’m surprised that it’s working at all. The onDateSet() gets called when the default onClick behavior is executed, but since you’re completely setting new buttons you’re getting rid of the original behavior. You can check the code out. Why are you not starting your activity in the onDateSet()? If what you want is to set the text, then you can get each button instead of setting them (getButton(BUTTON_POSITIVE)).

    Also, beware that there’s a new bug in Jelly Bean where the onDateSet will get called twice, will get called even if you press back AND they also removed the default Cancel button. Go figure.

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

Sidebar

Related Questions

Am using Date Picker in my screen. But the problem is its not displaying
Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
I am currently using a date and time picker to retrieve a user-submitted date
I am using a standard date picker to allow the user to pick a
I'm using the basic DatePickerDialog tutorial by Android found here Android Date Picker and
Using import datetime in python, is it possible to take a formatted time/date string
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Hello All: How to disable future dates in DatePickerDialog in Android. I am using
Using Xcode4.2.1, with a basic PhoneGap template based app. (I say template, but I
Using an ajax call I have returned the partialView HTML of a page, but

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.