android-datepicker
Android spinner with date picker, like Google Calendar app
Twaddington’s comment on his answer is actually the right approach. What you need is to create a text view and apply the style style=”@android:style/Widget.DeviceDefault.Light.Spinner” Then you can create a click listener on the text view and use it to open a DatePickerDialog. That can be accomplished as shown here: https://stackoverflow.com/a/8127571/332738 (If you follow the example, … Read more
Calender.getInstance() gives error in Android Studio
You have the wrong import statement for Calendar. It needs to be java.util.Calendar. My guess is that you have an import for android.icu.util.Calendar.
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.
Setting time and date to date picker and time picker in android
I solved a similar problem of mine as follows Calendar cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DAY_OF_MONTH); int hour = cal.get(Calendar.HOUR_OF_DAY); int min = cal.get(Calendar.MINUTE); datePicker.updateDate(year, month, day); timePicker.setCurrentHour(hour); timePicker.setCurrentMinute(min);
Get date from datepicker using dialogfragment
Constructor fo DatePickerDialog takes DatePickerDialog.OnDateSetListener as second parameter, so maybe you should implement that interface in your parent activity EditSessionActivity (not in DatePickerFragment ) and change this line: return new DatePickerDialog(getActivity(), this, year, month, day); into this: return new DatePickerDialog(getActivity(), (EditSessionActivity)getActivity(), year, month, day); And then your activity should looks like this: public class EditSessionActivity … Read more
Set Limit on the DatePickerDialog in Android?
All the other answers seem rather convoluted, so I’m just going to state the obvious: you can get the underlying DatePicker from a DatePickerDialog (by simply calling getDatePicker()) and set its bounds using: setMinDate(long minDate) setMaxDate(long maxDate) Where the argument is the usual number of milliseconds since January 1, 1970 00:00:00 in the default time … 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
Android – OnDateChangedListener – how do you set this?
Once you’ve created your DatePicker, you need to initialize it with the date you want to display at first. That’s the point at which you can add your listener. See DatePicker.init(int, int, int, OnDateChangedListener). Update 26 API allows to set listener: DatePicker.setOnDateChangedListener()
How to show DatePickerDialog on Button click? [closed]
I. In your build.gradle add latest appcompat library, at the time 24.2.1 dependencies { compile ‘com.android.support:appcompat-v7:X.X.X’ // where X.X.X version } II. Make your activity extend android.support.v7.app.AppCompatActivity and implement the DatePickerDialog.OnDateSetListener interface. public class MainActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener { III. Create your DatePickerDialog setting a context, the implementation of the listener and the start … Read more