您的位置:首页 > 移动开发 > Android开发

解决android SwipeRefreshLayout recyclerview 不能下拉

2015-11-19 14:43 246 查看
http://stackoverflow.com/questions/25178329/recyclerview-and-swiperefreshlayout

23down vote

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);
}
});


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: