2

我有 recyclerview,其中包含水平子回收器视图,最后它有一个无限滚动垂直回收器视图子

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

我已将 wrap_content 高度添加到子垂直回收器视图,因此我无法将滚动侦听器添加到此子回收器视图

我已经向最外层的父 recyclerview 添加了无限滚动侦听器,但滚动只能工作到第 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;
                    }
                }
            }
        }
4

0 回答 0