Date and time picker dialog
Solution 1
First make the time and date picker appear in the same dialog
Here i can help you some what: you can create a layout consisting of a DatePicker
and a TimePicker
in a LinearLayout
with the orientation set to vertical.
custom_dialog.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<DatePicker
android:id="@+id/datePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</DatePicker>
<TimePicker
android:id="@+id/timePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TimePicker>
</LinearLayout>
Then use this layout to create your dialog.
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("Custom Dialog");
To react to the user interacting with your TimePicker
, do something like this:
TimePicker tp = (TimePicker)dialog.findViewById(R.id.timepicker1);
tp.setOnTimeChangedListener(myOnTimechangedListener);
To get the values from the Date- and TimePicker when the user has finished setting them, add an OK button in your dialog, and then read the date and time values from the Date- and TimePicker when the user presses OK.
To make something that looks exactly as in your screen shots I recommend you to make all things custom with your own logic.
Solution 2
To change Blue bar colors try the below.
Define your own theme as follows,which extends THEME_HOLO_DARK
Try as follows:-
<style name="testo" parent="@android:style/Widget.DeviceDefault.DatePicker">
<item name="android:divider">@drawable/MyDivider</item>
</style>
Check the following change-basic-theme-color-of-android-application
Solution 3
Date Picker and Time Picker both in a single dialog. Check this simple and easy library. CustomDateTimePicker
Hope it helps. Happy coding!!!
haythem souissi
My core competency lies in Android development. I build nice and fast applications that uses Android SDK; I use cutting edge technologies and latest versions of the SDK while keeping compatibility with older Android APIs. I have experience in those areas: - Experience with Android UI design (including custom views) - Experience writing Android clients for Web Services (REST, RPC, and/or SOAP) - Experience with Android Activities and Fragments - Experience with multi-threaded development on Android platforms - Firm understanding of Intents, ContentProviders, Services, BroadcastReceivers, AsyncTask, Handlers and AIDL. - Experience with SQL Lite on Android - Experience with object-oriented design and design patterns - Experience using source code control systems such as Git - Knowledge of JSON and XML parsing, and/or DOM traversal. - Knowledge of work in an Agile development environment - Excellent verbal and written communication skills required -Creative problem solving skills and ability to effectively communicate and translate feedback, needs and solutions - I have strong teamwork orientation and the ability to foster collaboration within and across teams - Experience as developer on App(s) publicly available in the Google Play App Market - Experience with native Android UI development for phones and tablets (multi-resolutions, resource utilization such as images, layouts, strings) - Awareness of the Android UI/UX guidelines - Experience with mapping and search providers - Experience with other Google APIs (licensing, in-app billing, etc) - Experience developing Android Widgets ... Skills: - JSON et XML - Matérial Design - SQLite - Retrofit - JavaRx - Picture-in-Picture mode - Notifications - Autofill framework - WebView APIs - Multi-display support - Pointer capture - Android TV launcher - Animations - Content providers - MediaPlayer - File management - Wi-Fi, Bluetooth, Companion device pairing - Permissions - Multi-window Support - Vulkan API 3D - Multi-locale Support - Emojis Android - Geolocation - OpenGL - Printer et Printing - Frame Metrics API - AudioManager - Camera - NFC - Storage - Graphics I am seeking opportunities to build Android applications from the ground up for you or your business. I am looking for Long Term Partnership.
Updated on July 15, 2022Comments
-
haythem souissi almost 2 years
I want to create a dialog which can select the time and the date at the same time.
I know that there is not a default widget that can do that on Android. I also know that there are open source projects on how do similar staff. The problem in this project is that in the dialog we have two buttons: datePicker and timePicker.And that's not what I want to do - I want that the date and time picker appear at the same time.
So I think the two main problem will be:- First make the time and date picker appear in the same dialog.
- And the second problem will be to change the appearance of time and date picker (the orange color).
The first problem was resolved by Bhavesh. Here is what I get:
The problem now is that I want to change all blue bar color to orange color.
I addedandroid:calendarViewShown="false"
to remove the calendar in the right :) Thanks Bhavesh and I changed the theme to HOLO
Here is what I get:You can download the code (that's the best I can do). You can download from here.