Skip to content
Davide Steduto edited this page May 25, 2017 · 14 revisions

In this page


Main exposed listeners

Usually an Activity or Fragment can be an instance of multiple listener. Optionally a listener can be an object of your preference. All you need to do is to pass the listeners object to the Constructor of the FlexibleAdapter OR to call the same function addListener(listener) for all main types of listeners.

OnUpdateListener

OnDeleteCompleteListener

OnItemClickListener

OnItemLongClickListener

OnActionStateListener

OnItemMoveListener

OnItemSwipeListener

OnStickyHeaderChangeListener

To be continued...

Listener exposed through methods

EndlessScrollListener

To be continued...

Overridden listeners

BubbleTextCreator

OnScrollStateChangeListener

AdapterCallback

ViewHolderCallback

To be continued...

Others listeners

The list of listeners is not finished :-)
There are more listeners that are covered in the dedicated pages for the ActionModeHelper and UndoHelper. However, here we just mention them:

  • Android ActionMode.Callback
  • UndoHelper listeners
    • OnActionListener
    • OnUndoListener

To be continued...

Custom listeners

Follow these steps:

  1. Override FlexibleAdapter with your own CustomAdapter and create a public field for the Callback interface that can be used in the ViewHolder. From now on, you will instantiate only CustomAdapter.
  2. The constructor of the CustomAdapter accepts the implementation of the callback.
  3. The constructor of the ViewHolder accept your CustomAdapter instead of FlexibleAdapter so when you create the ViewHolder you cast the Adapter to CustomAdapter.
  4. Inside the click listener of your button/image you can call the callback interface: mAdapter.MyCallback, where mAdapter is a private field in the ViewHolder initialized in the constructor.
  5. The implementation of the callback can finally be done in the Activity / Fragment as a field or as implementation of the class itself.

Clone this wiki locally