I am trying to pick up the date of birth using a date picker. I am using the following code : -
new DatePickerDialog(SignUpOne.this, date, 1950,01,
01).show();
I have tested on HTC ONE S, and Galaxy S4 and Samsung Galaxy Grand Quattro. They are all showing the initial date as 1950,01,01
But when i am testing it with Lenovo K900 running Android 4.2.1 and it keeps showing the initial date as 1989-01-01.
Is there an alternative to set the initial date.
Try to use setMinDate() method of DatePicker, e.g.:
Calendar minPickerDate = Calendar.getInstance();
minPickerDate.set(Calendar.YEAR, 1900);
picker.setMinDate(minPickerDate.getTimeInMillis());
Related
I'm writing an android tv app with lean-back and I want to use android standard date picker and I want to make this like this pic
(eg: Made year part bigger when the user is selecting year and so on)
How can I achieve this?
You cannot use the standard date picker in Android TV apps because it was not designed for navigation using D-Pad. However, you can create your own widgets for day, month and year selection. You can simply use VerticalGridView to create them. For instance, you can do something similar to this for days:
<androidx.leanback.widget.VerticalGridView
android:id="#+id/vgv_days"
android:background="#color/transparent"
android:layout_marginEnd="10dp"
android:layout_width="40dp"
android:layout_height="35dp" />
customArrayObjectAdapterDays = new CustomArrayObjectAdapter(new DatePartPresenter(getContext()));
for (int i = 1; i < 31; i++) {
customArrayObjectAdapterDays.add(i);
}
vgvDays = (VerticalGridView) view.findViewById(R.id.vgv_days);
vgvDays.setNumColumns(1);
vgvDays.setAdapter(new ItemBridgeAdapter(customArrayObjectAdapterDays));
You also have to set the number of days (28, 29, 30, 31) depending on the year and selected month.
I am using code to hide Date in Date picker. It worked fine in devices having OS less than 7.0 [Android Nougat] device.
((ViewGroup) dpDialog.getDatePicker()).findViewById(Resources.getSystem().getIdentifier("day", "id", "android")).setVisibility(View.GONE);
No view is referenced, it returns null
findViewById(Resources.getSystem().getIdentifier("day", "id", "android"))
Before Android N, I can use the code below to instance a spnnier mode datepicker dialog:
new DatePickerDialog(getContext(), AlertDialog.THEME_HOLO_LIGHT, null, 2016, 9, 18);
but the above code is not work on Android N device, it always show the calander mode, is there something different in Android N? How can I instance a spinner mode datepicker dialog?
Have you tried something like : yourDatePickerDialog.getDatePicker().setCalendarViewShown(false);
In my cordova application i use jt sage date picker(v 1.3.0) inside the popup. Open date picker inside the popup using this SO answer now the problem after selecting the date the datepicker is not able to close.
<input name="mydate" id="mydate" type="date" data-role="datebox" data-options='{"mode": "datebox", "useNewStyle":true}'/>
In browser it is working fine but in my device(nexus 7) not working.
Here is the FIddle Demo
EDIT:
Now i noted another one problem when chaging the date or month in picker then again it come to the current date or month
Application type: mobile, Titanium SDK: 3.0, Platform & version: Android 4.1, Device: Samsung S3
when using the date picker i get a picker with three columns (day, month and year) but ALSO i am getting a calendar like box on the right containing the number of days. how can i remove the calendar box and keep the picker columns?? i am compiling against android 3.2 SDK
<android xmlns:android="http://schemas.android.com/apk/res/android">
<tool-api-level>13</tool-api-level>
<manifest>
<uses-sdk android:targetSdkVersion="13" android:minSdkVersion="13"/>
<!--
<uses-sdk android:minSdkVersion="10"/>
-->
</manifest>
</android>
my code:
var minDate = new Date();
var curMonth = 0;
for (var i = 0; i < 12; i++) {
curMonth = minDate.getMonth();
curMonth--;
minDate.setMonth(curMonth);
}
var now = new Date();
this.visitDatePicker = Ti.UI.createPicker({
type : Ti.UI.PICKER_TYPE_DATE,
maxDate : now,
value : now,
minDate : minDate,
selectionIndicator : true
});
i added a screenshot of what i mean, maybe i will get some replies :)
my problem is the box that appears on the right of the date picker, how can i get rid of it??
ok its a bug, see Android: Add calendarViewShown to picker TIMOB-12539 jira issue.
I spend more time debugging and optimizing titanium than actually writing code and business logic. my next project wont be using Titanium for sure....not acceptable