PullToRefresh list with pinned section header

后端 未结 4 1404
粉色の甜心
粉色の甜心 2020-12-30 11:50

Does anyone has practice of using Pull to refresh list with Pinned section header? I use Android-PullToRefresh lib with my list and I want to add a

4条回答
  •  甜味超标
    2020-12-30 12:17

    It's possible to integrate the Actionbar-PullToRefresh library with the StickyListHeaders library, but you need to use a custom Delegate in order to get Actionbar-PullToRefresh to work correctly:

    public class StickyListViewDelegate extends AbsListViewDelegate {
        @Override public boolean isReadyForPull(View view, final float x, final float y) {
        StickyListHeadersListView sticky = (StickyListHeadersListView) view;
        return super.isReadyForPull(sticky.getWrappedList(), x, y);
    }
    

    Integrated like so:

    StickyListViewDelegate delegate = new StickyListViewDelegate();
    ActionBarPullToRefresh.from(getActivity()).theseChildrenArePullable(mListView)
        .useViewDelegate(StickyListHeadersListView.class, delegate)
        .listener(this).setup(mPullToRefreshLayout);
    

    The reason that the two libraries don't work together is because the StickyListHeadersListView class does not actually extend ListView (which is what the Actionbar-PullToRefresh library looks for when assigning a delegate by default).

提交回复
热议问题