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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:02:16+00:00 2026-05-18T08:02:16+00:00

How can I create date and time settings dialog in Android? I want: 3

  • 0

How can I create date and time settings dialog in Android? I want:

  • 3 fields – day, hours and minutes
  • it should look native to the system – that makes writing my own widget quite hard – how to make the plus/minus buttons above/below each field look like the standard buttons that are in TimePickerDialog? I mean even on HTC Sense.
  • 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-18T08:02:16+00:00Added an answer on May 18, 2026 at 8:02 am

    Create buttons that you’ll use to both display the date and time, and trigger the date and time dialogs.

    Example code :

        fromDatePicker = (Button) findViewById(R.id.fromDatePicker);
        fromDatePicker.setText(dateNow);
        fromDatePicker.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                showDialog(FROM_DATE_DIALOG_ID);
            }
        });
    
        fromTimePicker = (Button) findViewById(R.id.fromTimePicker);
        fromTimePicker.setText(timeNow);
        fromTimePicker.setOnClickListener(new View.OnClickListener() {
    
            public void onClick(View v) {
                showDialog(FROM_TIME_DIALOG_ID);
            }
        });
    

    Create your dialogs like this :

    @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
            case FROM_TIME_DIALOG_ID:
                return new TimePickerDialog(this,fromTimeSetListener, fromHour, fromMinute, false);
            case FROM_DATE_DIALOG_ID:
                return new DatePickerDialog(this,fromDateSetListener,fromYear, fromMonth, fromDay);
            case TO_TIME_DIALOG_ID:
                return new TimePickerDialog(this,toTimeSetListener, toHour, toMinute, false);
            case TO_DATE_DIALOG_ID:
                return new DatePickerDialog(this,toDateSetListener,toYear, toMonth, toDay);                
        }
        return null;
    }
    

    Your screen will look like this :

    alt text

    When clicking the date button, a datepicker will popup looking like this :

    alt text

    When clicking the time button, a timepicker will popup looking like this :

    alt text

    Android doesn’t offer a combined DateTimePicker dialog out of the box… If you want to combine both the date and timepicker on 1 screen or dialog you have 3 options :

    Work with the UI widgets in a layout/view :

    <TimePicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />  
    
    <DatePicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />  
    

    Find a third party component offering this functionality

    There’s a custom datetimepicker at http://code.google.com/p/datetimepicker

    Write one yourself

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

Sidebar

Related Questions

No related questions found

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.