解决android SwipeRefreshLayout recyclerview 不能下拉

http://*.com/questions/25178329/recyclerview-and-swiperefreshlayout

write the following code in addOnScrollListener of the RecyclerView

Like this:

        recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener(){
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            int topRowVerticalPosition =
                    (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop();
            swipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0);

        }

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
        }
    });





上一篇:c/c++ static关键字详解


下一篇:以CPS(网络-实体系统)为核心的智能化大数据创值体系