-
Notifications
You must be signed in to change notification settings - Fork 553
5.x | ViewHolders
Davide Steduto edited this page Jun 25, 2016
·
22 revisions
###Create/Binding ViewHolders
####Method A (new!)
#####Item interfaces
Via Model objects. In this case you don't need to implement onCreateViewHolder()
and onBindViewHolder()
adapter methods, but getLayoutRes()
createViewHolder()
and bindViewHolder()
inside the implementation of item interfaces.
@Override
public int getLayoutRes() {
return R.layout.recycler_expandable_row;
}
@Override
public ViewHolder createViewHolder(FlexibleAdapter adapter, LayoutInflater inflater, ViewGroup parent) {
return new ViewHolder(inflater.inflate(getLayoutRes(), parent, false), adapter);
}
@Override
public void bindViewHolder(final FlexibleAdapter adapter, ViewHolder holder, int position, List payloads) {
//Bind your VH
}
The ViewHolder
class is an inner static class of the same item interface.
####Method B
You override and implement onCreateViewHolder()
and onBindViewHolder()
adapter methods as usual.
For multiple view types you will need to add a switch
statement in both methods and cast the specific item where necessary.
ViewHolders are as well defined all in the same adapter class.
- Update Data Set
- Selection modes
- Headers and Sections
- Scrollable Headers and Footers
- Expandable items
- Drag&Drop and Swipe
- EndlessScroll / On Load More
- Search Filter
- FastScroller
- Adapter Animations
- Third party Layout Managers
- Payload
- Smooth Layout Managers
- Flexible Item Decoration
- Utils
- ActionModeHelper
- AnimatorHelper
- EmptyViewHelper
- UndoHelper
* = Under revision!