Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PullToRefresh list with pinned section header

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.

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

like image 566
dimetil Avatar asked Jun 24 '13 09:06

dimetil


2 Answers

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

like image 116
Andrew Emery Avatar answered Nov 14 '22 10:11

Andrew Emery


I did some research and I found 2 alternatives:

  1. StickyListHeaders. This library is contributed by Jake Wharton (reference) so it is promising and could be compatible with other libraries. You should try to use it.
  2. PinnedSectionListView - easy to use ListView with pinned sections for Android.

You can try combining these two libraries with ActionBar-PullToRefresh. I suppose you can implement the solution ;)

like image 4
mmBs Avatar answered Nov 14 '22 11:11

mmBs