Pulltorefresh List With Pinned Section Header
Solution 1:
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:
publicclassStickyListViewDelegateextendsAbsListViewDelegate {
@OverridepublicbooleanisReadyForPull(View view, finalfloat x, finalfloat y) {
StickyListHeadersListViewsticky= (StickyListHeadersListView) view;
returnsuper.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).
Solution 2:
I did some research and I found 2 alternatives:
- 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.
- 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 ;)
Solution 3:
You can use a combination of SwipeRefreshLayout of support-library and the PinnedHeaderListview.
In your XML file, use like following:
<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 codes for your PinnedHeaderListView as usual. Finally just put a Refresh Listener for your SwipeRefreshLayout like below:
pinned_lisview_container
.setOnRefreshListener(newOnRefreshListener() {
@OverridepublicvoidonRefresh() {
// do your refresh tasks here
}
});
You are done.
Solution 4:
SwipeRefreshLayout + any other suitable library that you would use can do the job. I would prefer PinnedSectionListView beacuse it uses Listview and it has it its pros in terms of UI/UX.
Post a Comment for "Pulltorefresh List With Pinned Section Header"