Deprecated since AndroidX introduce MergeAdapter can do same thing as we do.
Compose multiple Adapter for RecyclerView in Android
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
// ...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
compile 'com.github.jintin:MixAdapter:1.1'
}
For simple usage add all your adapter into MixAdapter
then done.
MixAdapter<RecyclerView.ViewHolder> adapter = new MixAdapter<>();
adapter.addAdapter(adapterA);
adapter.addAdapter(adapterB);
recyclerView.setAdapter(adapter);
You can see more example in app
module or clone to run.
Bug reports and pull requests are welcome on GitHub at https://github.com/Jintin/MixAdapter.
The module is available as open source under the terms of the MIT License.