我想用节标题实现类似网格的布局。想想https://github.com/TonicArtos/StickyGridHeaders
我现在应该做什么:
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);
现在常规项目和页眉的跨度大小均为1。如何解决此问题?
mAdapter.getItemViewType(position)
返回正确的值?