RecycleView的上啦加载更多

一句话教你搞定RecycleView的上啦加载更多

LinearLayoutManager layoutManager;
layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerview.setLayoutManager(layoutManager);

mRecyclerview.addOnScrollListener(new OnScrollListener() { 

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 
                super.onScrolled(recyclerView, dx, dy);
                int visible  = layoutManager.getChildCount();
                int total = layoutManager.getItemCount(); 
                int past=layoutManager.findFirstCompletelyVisibleItemPosition();
                if ((visible + past) >= total){
                        mType=2;page++;
                        initData(); 
                }
            } 
        });

你可能感兴趣的:(上拉加载更多,RecycleVie)