我使用GridLayoutManager
到RecyclerView
,但我需要每四行一次(提供图像)ViewType
给我解决办法
答案 0 :(得分:0)
RecyclerView
支持多个viewtypes
。
看看这个:
How to create RecyclerView with multiple view type?
@Override
public int getItemViewType(int position) {
//Every 5th view should be different
return position % 5;
}
@Override
public int getItemCount() {
return 2;
}
答案 1 :(得分:0)
假设所有项目都具有相似的视图,请尝试以下操作:
GridLayoutManager layoutManager = new GridLayoutManager(DashboardActivity.this, 2);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (positions you wish to have a different view) {
return 2;
}
return 1;
}
});