当前位置: 首页>>代码示例>>Java>>正文


Java GridLayoutManager.setSpanCount方法代码示例

本文整理汇总了Java中android.support.v7.widget.GridLayoutManager.setSpanCount方法的典型用法代码示例。如果您正苦于以下问题:Java GridLayoutManager.setSpanCount方法的具体用法?Java GridLayoutManager.setSpanCount怎么用?Java GridLayoutManager.setSpanCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.GridLayoutManager的用法示例。


在下文中一共展示了GridLayoutManager.setSpanCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //导入方法依赖的package包/类
public static void onAttachedToRecyclerView(RecyclerView.Adapter innerAdapter, RecyclerView recyclerView, final SpanSizeCallback callback)
{
    innerAdapter.onAttachedToRecyclerView(recyclerView);

    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager)
    {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();

        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup()
        {
            @Override
            public int getSpanSize(int position)
            {
                return callback.getSpanSize(gridLayoutManager, spanSizeLookup, position);
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:WrapperUtils.java

示例2: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //导入方法依赖的package包/类
public static void onAttachedToRecyclerView(RecyclerView.Adapter innerAdapter, RecyclerView recyclerView, final SpanSizeCallback callback) {
    innerAdapter.onAttachedToRecyclerView(recyclerView);

    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();

        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                return callback.getSpanSize(gridLayoutManager, spanSizeLookup, position);
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }
}
 
开发者ID:guzhigang001,项目名称:Bailan,代码行数:18,代码来源:WrapperUtils.java

示例3: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //导入方法依赖的package包/类
public static void onAttachedToRecyclerView(RecyclerView.Adapter innerAdapter, RecyclerView
        recyclerView, final SpanSizeCallback callback) {
    innerAdapter.onAttachedToRecyclerView(recyclerView);

    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager
                .getSpanSizeLookup();

        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                return callback.getSpanSize(gridLayoutManager, spanSizeLookup, position);
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }
}
 
开发者ID:zuoni1018,项目名称:CoordinatorLayoutExample-master,代码行数:20,代码来源:WrapperUtils.java

示例4: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //导入方法依赖的package包/类
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    mInnerAdapter.onAttachedToRecyclerView(recyclerView);

    LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();

        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                int viewType = getItemViewType(position);
                if (viewType == TYPE_REFRESH_HEADER) {
                    return gridLayoutManager.getSpanCount();
                } else if (viewType == TYPE_LOADMORE_FOOTER) {
                    return gridLayoutManager.getSpanCount();
                }
                if (spanSizeLookup != null)
                    return spanSizeLookup.getSpanSize(position);
                return 1;
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }
}
 
开发者ID:BittleDragon,项目名称:RefreshLoadRecyclerview,代码行数:27,代码来源:ExcellentRecyclerview.java

示例5: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //导入方法依赖的package包/类
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    mInnerAdapter.onAttachedToRecyclerView(recyclerView);

    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();

        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                int viewType = getItemViewType(position);
                if (mHeaderViews.get(viewType) != null) {
                    return gridLayoutManager.getSpanCount();
                } else if (mFooterViews.get(viewType) != null) {
                    return gridLayoutManager.getSpanCount();
                }
                if (spanSizeLookup != null)
                    return spanSizeLookup.getSpanSize(position);
                return 1;
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }
}
 
开发者ID:BittleDragon,项目名称:MyRepository,代码行数:27,代码来源:MultiFunctionalWrapper.java

示例6: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //导入方法依赖的package包/类
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    mInnerAdapter.onAttachedToRecyclerView(recyclerView);
    //为了兼容GridLayout
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();

        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                int viewType = getItemViewType(position);
                if (mHeaderViews.get(viewType) != null) {
                    return gridLayoutManager.getSpanCount();
                } else if (mFooterViews.get(viewType) != null) {
                    return gridLayoutManager.getSpanCount();
                }
                if (spanSizeLookup != null)
                    return spanSizeLookup.getSpanSize(position);
                return 1;
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }

}
 
开发者ID:GuoZhaoHui628,项目名称:SliderStatusBar,代码行数:28,代码来源:HeaderAndFooterWrapperAdapter.java

示例7: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //导入方法依赖的package包/类
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    mInnerAdapter.onAttachedToRecyclerView(recyclerView);
    //设置HeaderView的ViewHolder的缓存数量
    if (null != mHeaderDatas && !mHeaderDatas.isEmpty()) {
        for (HeaderData headerData : mHeaderDatas) {
            recyclerView.getRecycledViewPool().setMaxRecycledViews(headerData.getLayoutId(), headerData.getCacheSize());
        }
    }
    //为了兼容GridLayout
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();

        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                int viewType = getItemViewType(position);
                if (isHeaderViewPos(position)) {
                    return gridLayoutManager.getSpanCount();
                } else if (mFooterViews.get(viewType) != null) {
                    return gridLayoutManager.getSpanCount();
                }
                if (spanSizeLookup != null)
                    return spanSizeLookup.getSpanSize(position);
                return 1;
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }

}
 
开发者ID:GuoZhaoHui628,项目名称:SliderStatusBar,代码行数:34,代码来源:HeaderRecyclerAndFooterWrapperAdapter.java

示例8: onAttachedToRecyclerView

import android.support.v7.widget.GridLayoutManager; //导入方法依赖的package包/类
@Override
public void onAttachedToRecyclerView(final RecyclerView recyclerView)
{
    mInnerAdapter.onAttachedToRecyclerView(recyclerView);

    final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager)
    {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();

        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup()
        {
            @Override
            public int getSpanSize(int position)
            {
                if (isShowLoadView(position))
                {
                    return gridLayoutManager.getSpanCount();
                }
                if (spanSizeLookup != null)
                {
                    return spanSizeLookup.getSpanSize(position);
                }
                return 1;
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }

    recyclerView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()){
                case MotionEvent.ACTION_DOWN:
                    lastY = event.getRawY();
                    break;
                case MotionEvent.ACTION_MOVE:
                    isPullUp = event.getRawY() < lastY ;
                    break;
            }
            lastY  = event.getRawY();
            return false;
        }
    });

    recyclerView.addOnScrollListener(new OnRcvScrollListener(){
        @Override
        protected void onLoadMore() {
            super.onLoadMore();
            if(isEnableLoad() && isPullUp && !mRefreshing){
                isLoadingMore = true;
                mOnLoadMoreListener.onLoad();
            }
        }

        @Override
        protected void showLoadView() {
            super.showLoadView();
            if(isEnableLoad() && isPullUp && !mRefreshing) {
                mLoadView.setLoadViewType(BaseLoadView.TYPE_LOAD_MORE);
            }
        }
    });

}
 
开发者ID:evansherry,项目名称:PullRefreshLoadMore,代码行数:67,代码来源:LoadMorePresenter.java


注:本文中的android.support.v7.widget.GridLayoutManager.setSpanCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。