Build a social feed app where posts, images, and ads each look different in the same scrolling list
Create a settings screen with mixed row types such as toggles, headers, and buttons without tangled code
Add a new item style to an existing list without touching any of the code already written
Display the same data type in multiple visual formats depending on a flag inside the data
Add the Maven dependency, create a delegate class per item type, register delegates with MultiTypeAdapter, and attach to your RecyclerView. AndroidX required. Use v3.x for Java projects.
MultiType is an Android library written in Kotlin that makes it easier to build scrolling lists where different items in the list look different from each other. On Android, scrolling lists are typically built using a component called RecyclerView. By default, adding multiple visual styles to one list requires a fair amount of repetitive, error-prone code that becomes harder to change over time. MultiType is designed to remove that friction. The core idea is to separate each visual style into its own small class, called a delegate. Instead of one large adapter class that knows about every item type in the list, you register individual delegates with the adapter, one per type. When the list needs to display a particular kind of item, the adapter forwards that item to the matching delegate, which knows how to draw it. Adding a new item type means creating a new delegate class and registering it, none of the existing code needs to change. The library also supports a one-to-many mapping, where a single data type can be displayed in more than one way depending on the content of the item. A linker function inspects each item and decides which delegate should handle it. This handles cases like a feed where items of the same category should render differently based on some flag or value inside the data. An Android Studio plugin is available separately that generates the boilerplate files for a new item type automatically, reducing the setup work further. MultiType is licensed under the Apache 2.0 license. It requires AndroidX and is written fully in Kotlin from version 4 onwards. A legacy Java-compatible version (3.x) is available for projects that have not migrated.
← drakeet on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.