explaingit

yanzhenjie/swiperecyclerview

5,713JavaAudience · developerComplexity · 2/5Setup · easy

TLDR

Android library that adds swipe menus, drag-to-reorder, swipe-to-delete, sticky headers and footers, and automatic load-more pagination to the standard Android RecyclerView list component.

Mindmap

mindmap
  root((repo))
    What it does
      Enhanced list view
      Android RecyclerView
      Gesture handling
    Features
      Swipe menus
      Drag to reorder
      Load more
    UI extras
      Header views
      Footer views
      Custom indicators
    Layouts
      Vertical list
      Grid layout
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add a swipe-left delete button to each row in an Android list without building gesture handling from scratch.

USE CASE 2

Let users long-press and drag list items to a new position, updating the data model via a callback.

USE CASE 3

Add a sticky header and footer around a RecyclerView, such as a search bar at top and a load-more button at bottom.

USE CASE 4

Automatically fetch the next page of data when a user scrolls to the bottom, with a built-in loading indicator.

Tech stack

JavaAndroidGradleAndroidX

Getting it running

Difficulty · easy Time to first run · 30min

Grid layout drag-and-drop requires a different item-swapping algorithm than list layout, example code is included in the README.

In plain English

SwipeRecyclerView is an Android library written in Java that extends the standard scrollable list component, called RecyclerView, with several interaction features that the built-in version does not include. The README is written in Chinese, so this explanation is based on what the code and documentation describe. The main additions are swipe menus on list items, drag-to-reorder, swipe-to-delete, and the ability to add fixed header and footer views above and below the list content. When a user swipes left or right on a row, a menu can appear on either side with buttons like delete, edit, or any custom action. The library supports both horizontal and vertical list layouts as well as grid layouts for this feature. Drag-to-reorder lets a user long-press a row and move it to a different position in the list. Swipe-to-delete lets a user flick a row off the screen to remove it. Both behaviors are disabled by default and must be turned on explicitly. The library provides callbacks so the app can update its data when items are moved or deleted. Header and footer views are plain Android views that sit outside the normal list items, at the top and bottom. They can be added or removed at any time without needing to rebuild the list adapter. A load-more feature is also included. As a user scrolls to the bottom, the library can automatically trigger a callback to fetch additional data and display a loading indicator. A default indicator view is provided, or a custom one can be substituted. The library is available through Gradle and supports both the older Android support library and AndroidX. Grid layout drag-and-drop requires a slightly different data-swapping algorithm than list layout, which the README documents with example code.

Copy-paste prompts

Prompt 1
I'm using SwipeRecyclerView in my Android app. Write the Java code to add a swipe-left menu with a Delete button to each row, and update my ArrayList when the user taps Delete.
Prompt 2
Show me how to enable drag-to-reorder in SwipeRecyclerView using long-press, including the callback I need to implement to update my data list when the user drops an item in a new position.
Prompt 3
I want to add a load-more feature to my SwipeRecyclerView that fetches the next page from my REST API when the user hits the bottom. Show the setup code and how to swap in a custom loading view.
Prompt 4
How do I add a fixed header view above and a footer view below my SwipeRecyclerView list? Show the layout XML and Java code, and how to remove them dynamically at runtime.
Open on GitHub → Explain another repo

← yanzhenjie on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.