Recyclerview from out to now basically widely used, but for me such a lot of things will not be used. Basic use includes ListView mode and GridView mode, recently using the GridView pattern, which is using Gridlayoutmanager to discover a useful method that can be used as a table merge cell in Word, merging some cells.
Using the method, call a method after getting Gridlayoutmanager:
Specific use
Gridlayoutmanager. (New Gridlayoutmanager.spansizelookup () {
@Override public
int getspansize (int position) {
int type = Indexrecyclerview.getadapter (). Getitemviewtype (position);//Get return value
//logutils.e ("TAG", "type:" +type);
if (type = = 1 | | type = = 2 | | type = = 3) {
return 2;//two
} else {
return 1;}}
);
Gets the type by combining the Getitemviewtype (position) method of the Recyclerview adapter.
@Override public
int getitemviewtype (int position) {
//LOGUTILS.E ("TAG", "Position-type:" +position);
if (position = = 0) {
return type_viewpager;
} else if (position = = 1) {
return type_operation;
} else if (position = = 2) {
return type_guider;
} else {
return type_gridview;
}
}
With this approach, we can easily merge a few grids in Gridvewi mode. Record here for easy follow-up search
The previous writing has been changed, no effect diagram, on the Internet to find an effect chart as follows: (the image below is the effect of merging the first second cell)