I am trying to figure out how to set default display year wise in Android Dialog DatePicker
. Our scenario is first user have to select the year then month and finally date in dialog DatePicker
. For this requirement we need to open year wise display on opening of the dialog.
PFB Image link. Kindly refer to right side image which should open by default.
you can use Calendar and subtract years you want , for example:
public Dialog onCreateDialog(Bundle saveInstanceState)
{
final Calendar c = Calendar.getInstance();
c.add(Calendar.YEAR, -18);
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(getActivity(), this, year, month, day);
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments