How to set default display as year wise in Android Dialog datepicker

user6457240

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.

DatePicker

user7258333

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.

edited at
0

Comments

0 comments
Login to comment

Related

How to change Default year(1900) of datepicker Dialog in android?

How to have datepicker set default year?

How set maximum date in datepicker dialog in android?

how to set datepicker dialog in android to yesterday date

How to Display Pie Chart Year wise in Pandas

How to display fullCalendar default view to day wise from month wise?

Display Current date in datepicker dialog in android

Set minimum year (use to select DOB) for Datepicker dialog

Datepicker default year error

How to set colors for DatePicker dialog in Xamarin?

How to set the size of my Dialog depends on the MainWindow (MVVM wise)

Set default date (in other formats) in a DatePicker - Android

Android Java - how to get day of year in DatePicker?

How to change DatePicker dialog color for Android 5.0

How to set XAML Element to default to current year?

How to set default time for QML DatePicker?

How to dynamically set default date in datepicker

How to set material dialog direction rtl as default?

How set default button on cancel in quasar dialog

How to set checkbox by default checked in checkbox dialog

How to set a default language on select language dialog?

Bootstrap Datepicker - Set default picker date, NOT display value

How to limit DatePicker to display only current year in React JS?

Mysql YEAR how to set the current year as default value

Android DatePicker Year not updating

Angular Dialog not display default

How to replace Android's default share dialog?

how to open android default share dialog in webview

Set year of datepicker using jquery