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);
Related
Time picker dialog shows circular timings by default to select date and time. Instead of it Need to show keyboard entry by default to select date and time. While showing time picker dialog in circular style, it has keyboard icon to change circular style to manual entry style. This feature is available from Android Oreo OS devices. How to show Time picker dialog with manual(keyboard) entry by default in supporting devices ?
The time picker can be started in text input mode with:
MaterialTimePicker.Builder().setInputMode(INPUT_MODE_KEYBOARD)
For example:
val picker =
MaterialTimePicker.Builder()
.setTitleText(R.string.Set_time)
.setTimeFormat(TimeFormat.CLOCK_12H)
.setHour(12)
.setMinute(30)
.setInputMode(MaterialTimePicker.INPUT_MODE_KEYBOARD)
.build()
picker.show(supportFragmentManager, "TimePicker")
Source: https://material.io/components/time-pickers/android#using-time-pickers
In your showTimePicker() function you can set the initialEntryMode.
By default it's TimePickerEntryMode.dial but you can change it to TimePickerEntryMode.input.
Just add: initialEntryMode: TimePickerEntryMode.input,
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"))
How is it possible to show a clock when opening a TimePickerDialog on preAPI21? I'm using appcompat-22 and I even found a way to show the new switch widget. I know how to change it in a regular layout: timePickerMode="clock/spinner" but couldn't find how to do it when opening a TimePickerDialog on API 19.
Please advice
I've recently begun updating my app to use appcompat-v22. One thing I've noticed is that on a Gingerbread emulator, the timepicker dialog is missing the AM/PM button.
I can click the empty space (inside the red circle in the below picture), and it will alternate between AM/PM, but I still can't see the actual button on the dialog.
Is this a bug in the SDK / compatability libraries, or maybe I did something horribly wrong when creating the dialog?
Edit: I didn't originally include my code, as it is very simple, I am not editing dialog themes at all. Note that it works as expected when using SDK v21 as the target.
TimePickerDialog timePickerDialog = new TimePickerDialog(adapter.getContext(), new TimePickerDialog.OnTimeSetListener() {
#Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// do stuff
}
}), reminderItem.hour, reminderItem.minute, false);
timePickerDialog.setTitle(R.string.createReminder);
timePickerDialog.show();
Fixed in Support Library 22.1.0
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());