Android – how to use setscrolllistener in staggeredgridview

I tried to add a scroll listener in staggeredgridview, where I couldn't find a way to add that I didn't see any implementation of GitHub URL https://github.com/maurycyw/StaggeredGridView thank you

resolvent:

Create a class that inherits swiperefreshlayout and overrides the canchildscrollup () method to check whether the staggeredgridview reaches the top. If it reaches the top, it returns true, otherwise it returns 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;
    }
}

}

In your activity or fragment, just send the moment of staggeredgridview, as shown below:

((SwipeDownToRefrsh)holder.swipeRefreshLayout).canChildScrollUp(holder.staggeredGridView);

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>