PullToRefresh List with Section Title Attached

Does anyone have any practice using a Pull to refresh list with a Pinned section header ? I am using the Android-PullToRefresh lib with my list, and I want to add the ability to display a title bar at the top of the list. I used the PinnedHeaderListView lib in another project for a pinned section. But I can not combine these two libraries into one.

Can Android-PullToRefresh show the header of a split section? Perhaps any other Pull to refresh lib can do this?

+8
android pull-to-refresh
source share
4 answers

You can integrate the Actionbar-PullToRefresh library with the StickyListHeaders library, but you need to use a custom delegate for 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 as follows:

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

The reason the two libraries do not work together is because the StickyListHeadersListView class does not actually extend the ListView (this is what the Actionbar-PullToRefresh library looks for when assigning a default delegate).

+9
source share

I did some research and I found 2 alternatives:

  • StickyListHeaders . This library is provided by Jake Wharton ( link ), so it is promising and may be compatible with other libraries. You should try to use it.
  • PinnedSectionListView is an easy-to-use ListView with attached sections for Android.

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

+4
source share

You can use a combination of the support-library SwipeRefreshLayout and PinnedHeaderListview .

In your XML file, use the following command:

 <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/pinned_lisview_container" android:layout_width="match_parent" android:layout_height="match_parent" > <za.co.immedia.pinnedheaderlistview.PinnedHeaderListView android:id="@+id/event_items_lisview" android:layout_width="match_parent" android:layout_height="match_parent" > </za.co.immedia.pinnedheaderlistview.PinnedHeaderListView> </android.support.v4.widget.SwipeRefreshLayout> 

And then in java code just write the codes for your PinnedHeaderListView, as usual. Finally, just add the Refresh listener for your SwipeRefreshLayout, as shown below:

 pinned_lisview_container .setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { // do your refresh tasks here } }); 

You are done.

+2
source share

SwipeRefreshLayout + any other suitable library that you use can do the job. I would prefer PinnedSectionListView beacuse to use Listview and has its advantages in terms of UI / UX.

0
source share

All Articles