dewinjm / monthyear-picker

Month and Year picker library for Android
Apache License 2.0
35 stars 14 forks source link

How to display selected month and year into dialog? #4

Closed CodingRookie97 closed 6 years ago

CodingRookie97 commented 6 years ago

After I have selected month and year, how to display that selected month and year as the default value shown in the dialog?

dewinjm commented 6 years ago

In the example I show you how to do it.

When you select a month and year, an OnDateSetListener event is triggered which returns the month and year selected in the dialog.

These values can be used by you when you raise the instance again to send these values.

// The monthSelected values are from (0-11) where 0 is January and 11 is December.
dialogFragment = MonthYearPickerDialogFragment
                .getInstance(monthSelected, yearSelected)

dialogFragment.setOnDateSetListener(new MonthYearPickerDialog.OnDateSetListener() {
  @Override
  public void onDateSet(int year, int monthOfYear) {
     monthSelected = monthOfYear // The monthOfYear values are from (0-11) where 0 is January and 11 is December.
     yearSelected = year
  }
})

See the Demo for your better understanding.

CodingRookie97 commented 6 years ago

Dear Developer,

Thank you for your immense help! Much appreciated!

Regards, CodingRookie97

On Mon, Aug 20, 2018 at 10:24 PM, Dewin J. Martinez < notifications@github.com> wrote:

Closed #4 https://github.com/dewinjm/monthyear-picker/issues/4.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dewinjm/monthyear-picker/issues/4#event-1797815161, or mute the thread https://github.com/notifications/unsubscribe-auth/AoR5QT4nrW3ksKeZZvdYzX80orxaM_amks5uSsaKgaJpZM4V3nVc .