HeaderListView with Pull to refresh

时间:2013-11-29 14:13:11

标签: android listview header pull-to-refresh

此帖与以下内容重复: PullToRefresh list with pinned section header &安培; is it possible to merge stickylistviewheader with crisbanes pulltorefresh?

我需要实现带有pull-to-refresh功能的headerListView。我正在谷歌搜索可能的方式来实现它,但仍然没有任何解决方案。

注意:有一个选项,使用mergeAdapter来实现分隔符,这个解决方案对我不起作用,因为我需要stickyHeader,而不是分隔符。

谢谢,

1 个答案:

答案 0 :(得分:1)

只要您在答案中使用Andrew Emery的自定义委托StickyListHeader

ActionBar-PullToRefresh就像as provided here的魅力一样;那就是:

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

如此整合:

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