一个实现了下拉刷新,滚动到底部加载更多以及添加header功能的的RecyclerView
一个实现了下拉刷新,滚动到底部加载更多以及添加header功能的的RecyclerView。使用方式和RecyclerView完全一致,不需要额外的layout,不需要写特殊的adater。 加载效果内置了AVLoadingIndicatorView上的所有效果,可以根据需要指定。
on real device it is much more smoother.
Usage
gradle
compile 'com.jcodecraeer:xrecyclerview:1.2.3'
just like a standard RecyclerView
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(layoutManager); mRecyclerView.setAdapter(mAdapter);
pull to refresh and load more
the pull to refresh and load more featrue is enabled by default. we provide a callback to trigger the refresh and LoadMore event.
mRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() { @Override public void onRefresh() { //refresh data here } @Override public void onLoadMore() { // load more data here } });
and of course you have to tell our RecyclerView when the refreshing or loading more work is done. you can use
mRecyclerView.loadMoreComplete();
to notify that the loading more work is done. and
mRecyclerView.refreshComplete();
to notify that the refreshing work is done.
here is what we get:
custom refresh and loading more style
pull refresh and loading more style is highly customizable.
custom loading style
the loading effect we use the AVLoadingIndicatorView . and it is built in(make a little change). we provide all the effect in AVLoadingIndicatorView library besides we add a system style. you can call
mRecyclerView.setRefreshProgressStyle(int style);
and
mRecyclerView.setLaodingMoreProgressStyle(int style);
to set the RefreshProgressStyle and LaodingMoreProgressStyle respectively.
for example
mRecyclerView.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader);
mRecyclerView.setLaodingMoreProgressStyle(ProgressStyle.SquareSpin);
BallPulse effect