Android Data Binding : Dynamic RecyclerView Adapter
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiz-sK09rE4OY5SEn4CrTCHg2pKXjNtY1EFIAFLQtesbVBlBHw3iZ29z2Bh0JAr4a0eEOKahMQ5rObLMSW4mu6uzi36rzP2ccOdJF5WoVI13119fOPbYSby0bP0Zv3wlNXMznyVooWQpyj5/s640/ezgif-4-19e52bb548.gif)
One of the most common list design patterns that I encounter as Android developer is a list with a variation of the following: Multiple row types. Expandable/Collapsible rows or sections. Load more/Scroll to load more. Delete rows/Sections. And all of these can be implemented in a generic manner with Android Data Binding library. You can write one adapter for all the RecycleView s in your app and use it to render all the common design patterns. Check out the source for the example in this tutorial here . Final result: Lets begin by defining our adapter: public class RecyclerViewBindingAdapter extends RecyclerView.Adapter<RecyclerViewBindingAdapter.BindingViewHolder> { private ObservableList<AdapterDataItem> data; public RecyclerViewBindingAdapter(ObservableList<AdapterDataItem> data) { this.data = data; data.addOnListChangedCallback(new ObservableListCallback()); } @Override public BindingViewHolder onCreateV