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
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"))
I'm targeting for and building with API level 21, using AppCompat v21.
It gives me a nicely looking new date picker, which has the unexpected property of allowing me to choose a future date when max date has been set using
datePicker.setMaxDate(Calendar.getInstance().getTimeInMillis())
The future dates are greyed out, but I can still choose any one of them. Is that a bug? Am I doing it wrong? Is there a way to prevent the user from being able to pick a future date in the date picker?
The old Holo date picker did not allow picking a future date when setting a maximum date.
UPDATE:
While it is not working properly on my Nexus 4 running stock 5.0, it is working properly on my Nexus 6 running stock Android 5.1.1. Perhaps it was a bug in Android 5.0 and it was fixed in 5.1? Can anyone confirm?
So to answer my own question:
I've looked at the Android source of DatePickerCalendarDelegate.java at grepcode, specifically at public void setMaxDate(long maxDate) for both Android versions 5.0 and 5.1.
What's new in 5.1 in setMaxDate() is that
mDayPickerView.goTo(getSelectedDay(), false, true, true);
has been changed to:
mDayPickerView.setMaxDate(maxDate);
It seems they fixed it there, which corresponds with my observation that it works as expected in 5.1 but not in 5.0.
And so it seems we're stuck with dealing with the fact that it doesn't work properly in Android 5.0 (days after max date are greyed out but can still be chosen).
I am using this and its working correctly
Call this function to open date picker
public void openDatePicker() {
DatePickerDialog dpd = new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay);
dpd.getDatePicker().setMaxDate(System.currentTimeMillis());
dpd.show();
}
Here is the mDateSetListener
private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
#Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
date.setText(dayOfMonth + " / " + (monthOfYear + 1) + " / " + year); // Here date is a TextView to display date
date.setVisibility(View.VISIBLE);
}
};
You can use a method in which u can pass the value of the date entered by the user and compare it for example to the current date , if it's a future date u can reset the value of date used to a specific one (for example the current date) and show a toast to inform him.
you can work around it on your CSS by finding the right element (with a "disabled" class) and setting a pointer events to none.`
.bs-datepicker-body table td.disabled {
pointer-events: none;
}
I want to show the current time in updatable textView
I can't find the true way to make it
I want it to be updated every minute
Please anyone can help me ?
Thanks
Calendar cal = Calendar.getInstance();
SimpleDateFormat oSimpleDateFormat = new SimpleDateFormat("HH:mm:ss");
String MyString= oSimpleDateFormat.format(cal.getTime());
EditText oEditText =(EditText) findViewById(R.id.MyEdit);
oEditText.setText(MyString);
try this
You should use ScheduledThreadPoolExecutor.scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html
use the digital clock tag Digital Clock built in android studio 2.1.
Here it is built in tag to show time
< Digital Clock > don't use space b/w digital and clock, it was having problem while posting the answer.
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());