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"))
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.
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);
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());
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
I am developing an application based on Android 2.1, on one page of my application, there needs an numberpicker. we know that android 2.1 doesn't contain numberpicker control, so I write one.
I need to show my version of numberpicker on Android 2.1, but the ICS style numberpicker in Android 4.0, to achieve that aim, I used reflection, When in my code, I detected the current Build.VERSION.SDK_INT >= 14, I reflect a numberpicker of the target platform, and add it to current view dynamically.
My question is I can reflect a numberpicker when I run my application on an Android 4.0 platform, but the numberpicker style doesnot appear to be ICS style, Why?
thanks in advance!
If you have the patience you could probably back-port the NumberPicker class. That aside, why use reflection? If you set your target API to 15 this is all you need. In your layout folder declare your alternative number picker. In layout-v11 (NumberPicker is available in API 11 Honeycomb or higher) declare android.widget.NumberPicker. Give each the same ID and in your Activity have something along these lines:
private NumberPicker mNumPicker;
private SomeView mOldNumPicker;
public void onCreate(...) {
// Use NumberPicker
if (android.os.Build.VERSION.SDK_INT >= 11) {
mNumPicker = findViewById(R.id.numpicker);
} else {
mOldNumPicker = findViewById(R.id.numpicker);
}
}
This was you do not need reflection and will not run into any crashes due to accessing non-existent APIs. From here on out you just check if (mNumPicker == null) and if (mOldNumPicker == null) and determine which methods to call based on that. There is also this example of a Number Picker using Buttons and an EditText.