Android: Complete, generic data-binding RecyclerView adapter
Data binding greatly reduces the amount of code you need to connect user-interfaces with ViewModels. It keeps Activity and Fragment code small, and makes it easier to manage lifecycles.
<EditText
android:id="@+id/username"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@={viewModel.username}"/>
I discovered that there was no attribute to bind the elements in a RecyclerView, due to the fact that a RecyclerView needs an adapter to be able to create element views. It would also be nice to automatically use data binding to create the viewholders. There are a number of guides to do both of these halves, but I now present the code to do the whole.
Read more of "Android: Complete, generic data-binding RecyclerView adapter"