android – 如何在StaggeredGridView中使用setScrollListener
作者:互联网
我试图在StaggeredGridView中添加Scroll监听器
在那里,我无法找到一种方法来补充说,我没有看到的任何实现
Github网址
https://github.com/maurycyw/StaggeredGridView
谢谢
解决方法:
创建一个继承SwipeRefreshLayout并覆盖canChildScrollUp()方法的类来检查StaggeredGridView是否到达顶部,如果到达顶部则返回true,否则返回false.
public class SwipeDownToRefrsh extends SwipeRefreshLayout{
PullToRefreshStaggeredGridView pullToRefreshStaggeredGridView;
public SwipeDownToRefrsh(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public void canChildScrollUp (PullToRefreshStaggeredGridView pullToRefreshStaggeredGridView) {
this.pullToRefreshStaggeredGridView = pullToRefreshStaggeredGridView;
}
@Override
public boolean canChildScrollUp() {
// TODO Auto-generated method stub
if (pullToRefreshStaggeredGridView == null) {
return true;
} else {
return !pullToRefreshStaggeredGridView.getRefreshableView().mGetToTop;
}
}
}
在您的Activity或Fragment中,只需发送StaggeredGridView的瞬间,如下所示:
((SwipeDownToRefrsh)holder.swipeRefreshLayout).canChildScrollUp(holder.staggeredGridView);
标签:android,android-layout,android-gridview 来源: https://codeday.me/bug/20190714/1460769.html