Using the picker view

maltaisn edited this page Jul 1, 2018 · 5 revisions

The dialog is what most people choose to select a recurrence, but you might want to include the picker view directly in your interface, or use it in a dialog with other widgets. For this purpose, you can use the RecurrencePickerView by itself.

<com.maltaisn.recurpicker.RecurrencePickerView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    />

The view has a few more settings than the dialog, you can set them with these methods:

  • setOnRecurrenceSelectedListener(@Nullable OnRecurrenceSelectedListener listener): Instead of the callback the dialog uses, the view uses a listener. The reason of this is that the dialog's caller activity might change during the dialog's lifetime, become the dialog instante in kept on configuration changes. Using a listener would be a memory leak.

    • listener: Listener to call when recurrence is selected and when cancel button is clicked. Set null to remove it.
  • setOnCreatorShownListener(@Nullable OnCreatorShownListener listener)

    • listener: Listener to call when picker view changes from option list to recurrence creator. This method may have limited use, but it is used by the dialog to briefly hide the dialog while its views and rearranged.
  • getRecurrence(): Get the currently selected recurrence.

Using the view in a dialog

Don't forget that if you are using the view in a dialog, you need to call:

  • setIsInDialog(true) to notify the view that it is in a dialog.

  • showDateDialogIfNeeded(): you need to call this method in your dialog's onShow listener to notify the view that it can now restore the date dialog if it was opened before restoring. This prevents the date dialog from being displayed behind your dialog because it was shown first.

For more information, look at the default RecurrencePickerDialog source code.

If you need to remove the header in the recurrence creator, look at the example in the styling section.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.