把一个不确定的进度作为页脚在RecyclerView网格 [英] Put an indeterminate progressbar as footer in a RecyclerView grid

查看:202
本文介绍了把一个不确定的进度作为页脚在RecyclerView网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得不确定的圆形指示灯为向上滚动加载更多在网格RecycleView?

How to get indeterminate circular indicator for "Scroll up to load more" in a grid RecycleView?

该模式有描述:<一href="http://www.google.com/design/spec/components/progress-activity.html#progress-activity-behavior">http://www.google.com/design/spec/components/progress-activity.html#progress-activity-behavior在两阶段负荷和示例2:向上滚动加载更多。例如视频

The pattern is described there: http://www.google.com/design/spec/components/progress-activity.html#progress-activity-behavior in "Two-phased loads" and "Example 2: Scroll up to load more" example videos.

我想这个使用新RecyclerView来完成,但我不能找到一个不太的hackish的方式来做到这一点,首先是因为没有一种方法来补充,涵盖了全行页脚在网格中。有什么建议?

I'm trying to accomplish this using the new RecyclerView, but I can't find a "not-too-hackish" way to do that, firstly because there is not a way to add a footer that cover a full row in the grid. Any suggestions?

推荐答案

这是很简单的事情了。 解决的办法是使用LinearLayoutManager的同样的方法用GridLayoutManager,然后使用方法setSpanSizeLookup上的布局管理这样

it is very simple to do that. The solution is to use the same approach of the LinearLayoutManager with a GridLayoutManager and then use the method setSpanSizeLookup on the LayoutManager like this

mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            switch(myAdapter.getItemViewType(position)){
                case MyAdapter.VIEW_TYPES.Product:
                    return 1;
                case MyAdapter.VIEW_TYPES.Progress:
                    return 2; //number of columns of the grid
                default:
                    return -1;
            }
        }
    });

此将自动进行的项目覆盖网格的一整行(如果行是不完全空此产品的进入下一行)。

This will automatically make the item cover a full row of the grid (if the row is not totally empty this item goes to the next row).

这篇关于把一个不确定的进度作为页脚在RecyclerView网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆