簡化RecyclerView使用:SuperRecyclerView
這個項目的目的是讓RecyclerView更容易使用。
內置功能:
- ProgressBar while adapter hasn't been set
- EmptyView if adapter is empty
- SwipeRefreshLayout (Google's one)
- Infinite scrolling, when you reach the X last item, load more of them.
- Swipe To Dismiss
- Sticky headers (via Eowise, see sample)
recycler.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener { @Override public void onRefresh() { // Do your refresh }); // when there is only 10 items to see in the recycler, this is triggered recycler.setupMoreListener(new OnMoreListener() { @Override public void onMoreAsked(int numberOfItems, int numberBeforeMore, int currentItemPos) { // Fetch more from Api or DB }}, 10); recycler.setupSwipeToDismiss(new SwipeDismissListViewTouchListener.DismissCallbacks() { @Override public boolean canDismiss(int position) { return true } @Override public void onDismiss(RecyclerView recyclerView, int[] reverseSortedPositions) { // Do your stuff like call an Api or update your db }});
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!