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

  • Home
  • SEARCH
  • 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 7510131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:08:21+00:00 2026-05-29T23:08:21+00:00

I want to add new button,which is clear button, to date picker widget and

  • 0

I want to add new button,which is clear button, to date picker widget and time picker widget in my android application. In default, these widgets have two button,set and cancel. How can I add one more button to these two button

Is it possible? If yes, can you give some example?

Thanks

  • 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-29T23:08:22+00:00Added an answer on May 29, 2026 at 11:08 pm

    This is how I implemented the “Clear” button in my app. When the user clicks Clear, the year/month/day values are all 0. You can use onDateSet() in your app for both the Set button and Clear button this way.

    I referenced the Android source code (\frameworks\base\core\java\android\app\DatePickerDialog.java).

    I also used the help of esilver.

    public class DatePickerDialogPlus extends DatePickerDialog {
        private final DatePicker mDatePicker;
        private final OnDateSetListener mCallBack;
    
        /**
         * @param context The context the dialog is to run in.
         * @param callBack How the parent is notified that the date is set.
         * @param year The initial year of the dialog.
         * @param monthOfYear The initial month of the dialog.
         * @param dayOfMonth The initial day of the dialog.
         */
        public DatePickerDialogPlus(Context context, OnDateSetListener callBack, 
                int year, int monthOfYear, int dayOfMonth) {
            super(context, 0, callBack, year, monthOfYear, dayOfMonth);
    
            mCallBack = callBack;
    
            Context themeContext = getContext();
            setButton(BUTTON_POSITIVE, 
                themeContext.getText(R.string.datePicker_setButton), this);
            setButton(BUTTON_NEUTRAL, 
                themeContext.getText(R.string.datePicker_clearButton), this);
            setButton(BUTTON_NEGATIVE, 
                themeContext.getText(R.string.datePicker_cancelButton), null);
            setIcon(0);
            setTitle(R.string.datePicker_title);
    
            LayoutInflater inflater = (LayoutInflater) 
                themeContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.date_picker_dialog, null);
            setView(view);
            mDatePicker = (DatePicker) view.findViewById(R.id.datePicker);
            mDatePicker.init(year, monthOfYear, dayOfMonth, this);
        }
    
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mCallBack != null) {
                if (which == BUTTON_POSITIVE) {
                    mDatePicker.clearFocus();
                    mCallBack.onDateSet(mDatePicker, mDatePicker.getYear(), 
                        mDatePicker.getMonth(), mDatePicker.getDayOfMonth());
                } else if (which == BUTTON_NEUTRAL) {
                    mDatePicker.clearFocus();
                    mCallBack.onDateSet(mDatePicker, 0, 0, 0);
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add a new time-field to a an existing MySQL-table that is
I want to add a new Stage called field to the default one (i
I want to add days to a date to get a new date in
I want to render a view when user clicks on Add New button on
I want to add button which will toggle between normal and satellite view in
i want to add a new View Which Contain Anything in a window based
I want to add multiple new JTextArea in JTextPane at runtime on button click.
I want to add a new tab page for every newly opened form. Example:
I want to add a new filter to the Project Explorer, to hide from
I want to add a new feature in a wxPython class. I also want

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.