I want to implement grid-like layout with section headers. Think of https://github.com/TonicArtos/StickyGridHeaders
What I do now:
mRecyclerView = (RecyclerView) view.findViewById(R.id.grid);
mLayoutManager = new GridLayoutManager(getActivity(), 2);
mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
switch(mAdapter.getItemViewType(position)){
case MyAdapter.TYPE_HEADER:
return 1;
case MyAdapter.TYPE_ITEM:
return 2;
default:
return -1;
}
}
});
mRecyclerView.setLayoutManager(mLayoutManager);
Now both regular items and headers have span size of 1. How do I solve this?
mAdapter.getItemViewType(position)
is returning the correct value ? – Knighthood