带有固定节标题的PullToRefresh列表

dim*_*til 8 android pull-to-refresh

有没有人有使用Pull to refresh列表的做法Pinned section header?我使用Android-PullToRefresh lib和我的列表,我想添加在列表顶部显示固定节标题的功能.我在另一个项目中使用了PinnedHeaderListView lib来获取固定部分.但我无法将这两个库合二为一.

Android-PullToRefresh是否可以显示固定部分标题?也许任何其他Pull to refreshlib都可以做到吗?

小智 9

可以将Actionbar-PullToRefresh库与StickyListHeaders库集成,但是您需要使用自定义Delegate才能使Actionbar-PullToRefresh正常工作:

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);
}
Run Code Online (Sandbox Code Playgroud)

整合如下:

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

这两个库不能一起工作的原因是因为StickyListHeadersListView类实际上并没有扩展ListView(这是Actionbar-PullToRefresh库在默认情况下分配委托时所查找的内容).


mmB*_*mBs 4

我做了一些研究,发现了两种替代方案:

  1. 粘性列表标题该库由 Jake Wharton(参考)贡献,因此它很有前途并且可以与其他库兼容。你应该尝试使用它。
  2. PinnedSectionListView - 易于使用的 ListView,带有适用于 Android 的固定部分。

您可以尝试将这两个库与 ActionBar-PullToRefresh 结合起来。我想你可以实施该解决方案;)

  • 这对于 StickyListHeaders 来说是不可能的。StickyListHeaders 从不支持的 FrameLayout 实现“ListView”。 (2认同)