當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。