0
回答
HeaderAndFooterRecyclerView的使用问题
【腾讯云】校园拼团福利,1核2G服务器10元/月!>>>   

@Cundong 你好,想跟你请教个问题:

EndlessRecyclerOnScrollListener类中,

public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        super.onScrolled(recyclerView, dx, dy);


        RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();


        if (layoutManagerType == null) {
            if (layoutManager instanceof LinearLayoutManager) {
                layoutManagerType = LayoutManagerType.LinearLayout;
            } else if (layoutManager instanceof GridLayoutManager) {
                layoutManagerType = LayoutManagerType.GridLayout;
            } else if (layoutManager instanceof StaggeredGridLayoutManager) {
                layoutManagerType = LayoutManagerType.StaggeredGridLayout;
            } else {
                throw new RuntimeException(
                        "Unsupported LayoutManager used. Valid ones are LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager");
            }
        }


如果设置了:

GridLayoutManager manager = new GridLayoutManager(this, 2);
        manager.setSpanSizeLookup(new HeaderSpanSizeLookup((HeaderAndFooterRecyclerViewAdapter) mRecyclerView.getAdapter(), manager.getSpanCount()));
        mRecyclerView.setLayoutManager(manager);
在滑动的时候, RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();

layoutManager类型是LayoutManagerType.LinearLayout,请前辈指点下吧。

<无标签>
举报
一叶飘舟
发帖于2年前 0回/829阅
顶部