Android Material Design Inline Datepicker issue

The calendarViewShown attribute is deprecated in the calendar-style date picker. If you want the spinner-style date picker back, you can set the datePickerMode attribute to spinner. <DatePicker … android:datePickerMode=”spinner” /> As for the scrolling issue, the calendar-style date picker doesn’t support nested scrolling.

How to change the style of a DatePicker in android?

call like this button5.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub DialogFragment dialogfragment = new DatePickerDialogTheme(); dialogfragment.show(getFragmentManager(), “Theme”); } }); public static class DatePickerDialogTheme extends DialogFragment implements DatePickerDialog.OnDateSetListener{ @Override public Dialog onCreateDialog(Bundle savedInstanceState){ final Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int day = … Read more

Android datepicker min max date before api level 11

You can set range with init datePicker method. Example with min value : // Calendar this.calendar = new GregorianCalendar(); this.datePicker = (DatePicker) findViewById(R.id.xxxxx); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // (picker is a DatePicker) this.datePicker.setMinDate(this.calendar.getTimeInMillis()); } else { final int minYear = this.calendar.get(Calendar.YEAR); final int minMonth = this.calendar.get(Calendar.MONTH); final int minDay = this.calendar.get(Calendar.DAY_OF_MONTH); this.datePicker.init(minYear, minMonth, minDay, … Read more

How to set minimum DatePicker date to current date

The error says you cannot set the minimum date to exactly now. Try subtracting a second: datePicker.setMinDate(System.currentTimeMillis() – 1000); From the source code the minimum date must be before, not equal to, the current date: if (date.before(mMinDate)) { throw new IllegalArgumentException(“fromDate: ” + mMinDate.getTime() + ” does not precede toDate: ” + date.getTime()); } So … Read more

MaterialDatePicker get selected dates

Just use the addOnPositiveButtonClickListener listener called when the user confirms a valid selection: For a single date picker: picker.addOnPositiveButtonClickListener(new MaterialPickerOnPositiveButtonClickListener<Long>() { @Override public void onPositiveButtonClick(Long selection) { // Do something… //Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(“UTC”)); //calendar.setTimeInMillis(selection); } }); For a range date picker: MaterialDatePicker<Pair<Long, Long>> pickerRange = builderRange.build(); pickerRange.show(….); pickerRange.addOnPositiveButtonClickListener(new MaterialPickerOnPositiveButtonClickListener<Pair<Long, Long>>() { @Override public void … Read more

How to disable dates before today date in DatePickerDialog Android?

Get the DatePicker used in your DatePickerDialog with the getDatePicker() method and use the setMinDate(Long millis) method. Pass to it the minimum date (in milliseconds from Epoch) you have to set. So you can do something like SimpleDateFormat sdf = new SimpleDateFormat(“dd/MM/yyyy”); Date d = sdf.parse(“21/12/2012”); DatePicker datePicker = date.getDatePicker(); datePicker.setMinDate(d.getTime()); EDIT: ok, so when … Read more

Android: why setVisibility(View.GONE); or setVisibility(View.INVISIBLE); do not work

I see quite a few things wrong. For starters, you don’t have your magic button defined and there is no event handler for it. Also you shouldn’t use: dp2.setVisibility(View.GONE); dp2.setVisibility(View.INVISIBLE); Use only one of the two. From Android documentation: View.GONE This view is invisible, and it doesn’t take any space for layout purposes. View.INVISIBLE This … Read more

Android DatePickerDialog: Set min and max date for selection

Try this method @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int day = calendar.get(Calendar.DAY_OF_MONTH); DatePickerDialog dialog = new DatePickerDialog(getContext(), listener, year, month, day); Field mDatePickerField; try { mDatePickerField = dialog.getClass().getDeclaredField(“mDatePicker”); mDatePickerField.setAccessible(true); } catch (Exception e) { e.printStackTrace(); } dialog.getDatePicker().setMinDate(System.currentTimeMillis() – 1000); return dialog; … Read more