How to localize Android DatePicker? - android

I put the DatePicker on my Activity. Everytime I launch my app I see english version of date in the DatePicker widget: Oct 15 2012. But I want to have a local version of date (russian) when I start my Activity. I've tried to define the locale before UI initialization. But it doesn't help. Is there any possibility to make it without extending DatePicker class?

In fact there is no need to override this class. But when I started to do it, I found info about special method "reorderpickers" which is specially designed to localize datepicker (automatically). My mistake was in setting Locale to English in the previous activity (to define English locale for password). That's why the standard method didn't work. So anybody who has the same problem check your code whether you have changed Locale.

You should create your custom datepickerdialog. For make this, that link help you;
http://coffeebreak.hiq.se/2011/09/09/fixing-androids-datepickerdialog/

Additional information for DataPicker and application locale you can find here

Related

How to reorder Android 8.0 language list in Welcome Page

As we all know, google put en_US first in the list, so make it default in android\o-base\build\target\product\full_base.mk file, but I don't want to change this file, and I had found the language list setting in LocalePicker.java the method getAllAssetLocales() to load all kinds of languages. But if I add "en-US", it will be the first in the language list, even I do add them like this order:
localeList.add("zh-CN");
localeList.add("th-TH");
localeList.add("vi-VN");
localeList.add("my-MM");
localeList.add("fr-FR");
localeList.add("ru-RU");
localeList.add("zh-HK");
localeList.add("en-US");
And I had also disabled sort() it, but it isn't work, the "en-US" still in the first of language list.
Anyone have another good idea? Thanks in advance.

Looking for the source code of the new Google Calendar Time and Date Picker Widgets

I would like to use the brand new Date Picker and Time Picker that is now part of the new official Google Calendar App.
http://googlesystem.blogspot.de/2013/05/new-google-calendar-controls-for-android.html
All I found so far is this source code on grepcode but I can't find the widgets or fragments or activities there.
http://grepcode.com/snapshot/repository.grepcode.com/java/ext/com.google.android/android-apps/4.2.2_r1/
Is that already public or is there something similar out there?
I think the code you are looking for can be found here:
https://android.googlesource.com/platform/frameworks/opt/datetimepicker/+/master/src/com/android/datetimepicker
There is some pretty directly usable source code snippets in this Android Developer Pages:
http://developer.android.com/guide/topics/ui/controls/pickers.html
I used it as-is and all works just fine.
Also, reference these:
DatePickerDialog
http://developer.android.com/reference/android/app/DatePickerDialog.html
TimePickerDialog
http://developer.android.com/reference/android/app/TimePickerDialog.html
DialogFragment
http://developer.android.com/reference/android/support/v4/app/DialogFragment.html

Android: Timpicker Difference declared in xml and in java code (TimePickerDialog)

So i have this problem of not getting accurate time result from timepicker declared in xml, not the dialog thing, i just wanted to know what is the difference from the two. so that i can know which is better to use on my app, mainly i use the timepicker to set an alarm or a reminder, because i have a hunch that the timpicker declared in xml is just for UI use not really for functionality. because i keep on getting the wrong result, specially dealing with AM and PM, Scenario is that when using timepicker declared in xml (not the dialog), i change first the hour den minutes and lastly the AM and PM, but i won't correctly give me the current time, say i chose 7:30 PM supposedly the value of the hour must be 19 since its 24-hour but instead it gives me 7:30 AM i won't change the AM and PM part thus giving me a wrong result, if you go the other way around, it works, it gives me ang accurate result.
SO my question is what is the MAIN difference between the two timepickers, is it for show(timepicker xml declared) and timepicker(dialog)
Please refer to this post for this problem, i just came across this thread and it is really the same with my problem. its a bug issue in Android
Android TimePicker AM/PM button not invoking onTimeChanged

How to customize a TimePickerDialog?

I'm looking to create something EXACTLY like TimePickerDialog (look and feel) in Android, but it would be for MINUTES/SECONDS, not HOURS/MINUTES. Therefore AM/PM would not be relevant and would therefore allow MINUTE to be greater than 24 (making the max 59).
Is it possible to change the TimePickerDialog instance in any way to reflect this?
Any and all suggestions would be greatly appreciated. :-)
Is it possible to change the TimePickerDialog instance in any way to reflect this?
No, but the layout and source code to TimePickerDialog are both available as a starting point for implementing your own dialog.
This might help:
TimePicker with seconds:
https://github.com/IvanKovac/TimePickerWithSeconds
Have a look.
As the links in CommonsWare's answer are now dead, you might want to know that the source for TimePickerDialog is probably already on your local machine - it is included in the SDK. Try looking in the following locations:
[SDK_HOME]/sources/android-23/android/app/TimePickerDialog.java
or
[SDK_HOME]/sources/android-23/com/android/datetimepicker/time/TimePickerDialog.java
[SDK_HOME]/platforms/android-23/data/res/layout/time_picker_dialog.xml
Of course, choose the Android version that you want to borrow from. References to R. should be to android.R. Unfortunately, there seem to be some visibility issues with ValidationCallback - even on recent SDK levels.

Android Calendar View for Date Picker

I'm writing my first app, and I have a question about DatePicker.
My app requires the user to input a date. The most user-friendly way would be to popup a calendar-like widget that displays the current month like a calendar grid - something like this:
I want to use that in place of the DatePicker interface - which has Month, Day, and Year fields, each with an up and down button to increment/decrement.
Is this type of functionality built into any Android widget or view, or would I have to design my own custom component to do this? I figured this would already exist, seeing how much this type of UI is used so frequently in non-mobile apps and web pages.
Thanks!
Now, in 2014, even the native DatePicker (link) contains small Holo looking CalendarView (link) to pick a day in month.
You can choose, if both spinners and CalendarView or just one of them is displayed by setting:
android:calendarViewShown
android:spinnersShown
I'm not sure if it's just API level 16+ or if it was even in Ice Cream Sandwich, but it's there. This is how it looks by default:
Moreover, on API level 21 and higher there is a new Material themed DatePicker that looks like following:
This is default on API 21+ and there are no spinners anymore, but you can switch back to the Holo one by setting
android:datePickerMode="spinner"
in your XML.
Since the API 11 there natively: CalendarView
This View is in HoloEverywhere since API 7.
Is this type of functionality built into any android widget or view, or would I have to design my own custom > component to do this?
There is no component for that in the Android SDK, sorry. The widget you illustrate is too small for a touchscreen. You can implement something larger (see the Calendar app), but you are largely on your own for that.
what i found so far:
http://code.google.com/p/android-calendar-view
http://code.google.com/p/openintents/wiki/CalendarPickerAPI
I have recently written exactly this as a modular app. Here is some sample code, documentation with screenshots, and .apk download.
Found a good implemetation in http://caughtinthemobileweb.wordpress.com/2011/06/20/how-to-implement-calendarview-in-android/
Also Since API level 11 (Android 3.0) there has been the native implementation of the CalendarView http://developer.android.com/reference/android/widget/CalendarView.html
Try to use this component:
https://github.com/truefedex/android-date-picker
If you want to use it like popup write on your onclick:
if (calendarPopup == null) {
calendarPopup = new PopupWindow(getContext());
CalendarPickerView calendarView = new CalendarPickerView(getContext());
CalendarNumbersView calendar = (CalendarNumbersView) calendarView.findViewById(com.phlox.datepick.R.id.calendar);
calendar.setShowDayNames(false);
calendarView.setListener(onDateSelectionListener);
calendarPopup.setContentView(calendarView);
calendarPopup.setWindowLayoutMode(
MeasureSpec.makeMeasureSpec(llCalendar.getWidth(), MeasureSpec.EXACTLY),
ViewGroup.LayoutParams.WRAP_CONTENT);
calendarPopup.setHeight(1);
calendarPopup.setWidth(llCalendar.getWidth());
calendarPopup.setOutsideTouchable(true);
}
calendarPopup.showAsDropDown(llCalendar);
you can use this lib for date selection
https://github.com/square/android-times-square/

Categories

Resources