{
556 |
557 | /**
558 | * Callback method to be invoked when an item in this view has been selected. This callback is invoked only when
559 | * the newly selected position is different from the previously selected position or if there was no selected
560 | * item.
561 | *
562 | * @param view The {@link MaterialSpinner} view
563 | * @param position The position of the view in the adapter
564 | * @param id The row id of the item that is selected
565 | * @param item The selected item
566 | */
567 | void onItemSelected(MaterialSpinner view, int position, long id, T item);
568 | }
569 |
570 | /**
571 | * Register a callback to be invoked when an item in the dropdown is selected.
572 | *
573 | * @param onItemSelectedListener The callback that will run
574 | */
575 | public void setOnItemSelectedListener(@Nullable OnItemSelectedListener onItemSelectedListener) {
576 | this.onItemSelectedListener = onItemSelectedListener;
577 | }
578 |
579 | /**
580 | * Interface definition for a callback to be invoked when the dropdown is dismissed and no item was selected.
581 | */
582 | public interface OnNothingSelectedListener {
583 |
584 | /**
585 | * Callback method to be invoked when the {@link PopupWindow} is dismissed and no item was selected.
586 | *
587 | * @param spinner the {@link MaterialSpinner}
588 | */
589 | void onNothingSelected(MaterialSpinner spinner);
590 | }
591 |
592 | /**
593 | * Register a callback to be invoked when the {@link PopupWindow} is shown but the user didn't select an item.
594 | *
595 | * @param onNothingSelectedListener the callback that will run
596 | */
597 | public void setOnNothingSelectedListener(@Nullable OnNothingSelectedListener onNothingSelectedListener) {
598 | this.onNothingSelectedListener = onNothingSelectedListener;
599 | }
600 | }
601 |
--------------------------------------------------------------------------------