嵌套的recyclerview无限滚动无法正常工作

时间:2017-01-27 09:12:28

标签: android android-recyclerview android-support-library nestedrecyclerview

我有的recyclerview包含水平子回收者视图,最后它有一个无尽的滚动垂直回收者视图子

<---RecyclerView-------->
    <Horizonatl recycler view>
    <Horizonatl recycler view>
    <Vertical recyler view endless scrolling>
<---RecyclerView-------->

我已将wrap_content高度添加到子垂直recyler视图,因此我无法将滚动列表器添加到此子recylerview

我已经向最外层的父回收者视图添加了无尽的滚动侦听器,但滚动工作直到第2页,然后它无法正常工作如何实现嵌套无限滚动。以下是我在父级Recyclerview上应用的侦听器代码

 @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            visibleItemCount = recyclerView.getChildCount();
            totalItemCount = layoutManager.getItemCount();
            firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
            if (dy > 0) {
                if (loading) {
                    if (totalItemCount > previousTotal) {
                        loading = false;
                        previousTotal = totalItemCount;
                        loading = false;
                        currentPage++;
                    }
                }
                if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) {
                    if (Utils.haveNetworkConnection(getActivity()) && currentPage < Constants.MAX_PAGES) {
                        loadMoreData();
                        loading = true;
                    }
                }
            }
        }

0 个答案:

没有答案