PullToRefresh列表寄托节头寄托、列表、PullToRefresh

2023-09-06 00:45:55 作者:一别便不再见

有没有人有使用实践拉刷新列表寄托节头? 我使用的Andr​​oid PullToRefresh lib中与我的清单,我想补充表示寄托节头的能力,在列表的顶部。我用 PinnedHeaderListView LIB在另一个项目中固定部分。但我不能结合这两个库为一体。

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 ability of showing pinned section header at the top of list. I used PinnedHeaderListView lib in another project for pinned section. But I can't combine these two libraries into one.

时的Andr​​oid PullToRefresh可以显示固定节头?也许,任何其他拉刷新 lib中能做到这一点?

Is Android-PullToRefresh can show pinned section header? Perhaps any other Pull to refresh lib can do it?

推荐答案

这是可能的整合动作条,PullToRefresh 库与 StickyListHeaders 库,但你需要使用一个自定义委托,以获得动作条,PullToRefresh正常工作:

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

这两个库不在一起工作的原因是因为StickyListHeadersListView类不实际的ListView扩展(这是什么动作条,PullToRefresh图书馆查找指定一个委托时默认的)。

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).