Skip to content
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.

Clone this wiki locally