I Created a Custom Data Picker in which i am showing years from 1950- 2016. now when i first open the picker i want to set current data of the day. but i am not able to set it
I want to set the current date of the day as picker open up for the first time..
IMO, that's because of the following lines:
m_calendar.set(Calendar.DAY_OF_MONTH, month);
m_calendar.set(Calendar.MONTH, day);
m_calendar.set(Calendar.YEAR, year);
It should be as the following:
m_calendar.set(Calendar.DAY_OF_MONTH, day);
m_calendar.set(Calendar.MONTH, month);
m_calendar.set(Calendar.YEAR, year);
or simply call m_calendar.set(year, month, day);
Please note that in Calendar.java file:
public static final int JANUARY = 0;
public static final int FEBRUARY = 1;
...
So if you want FEBRUARY
, you should use m_calendar.set(1, month, day);
or m_calendar.set(Calendar.FEBRUARY, month, day);
. In other words, if you call openDatePicker(3, 20, 2015);
the DatePicker will show the date April 20, 2015
.
Hope it helps!