I was going through the project and came across that we are using ListView while showing the Tasks in the TasksActivity and not RecyclerView. May I know why we are doing that? Is there a limitation that DataBinding may not support RecyclerView?
<LinearLayout
android:id="@+id/tasksLL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="@{viewmodel.empty ? View.GONE : View.VISIBLE}">
<TextView
android:id="@+id/filteringLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:gravity="center_vertical"
android:layout_marginLeft="@dimen/list_item_padding"
android:layout_marginRight="@dimen/list_item_padding"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:text="@{viewmodel.currentFilteringLabel}" />
<ListView
android:id="@+id/tasks_list"
app:items="@{viewmodel.items}"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
I think this is used to keep it simple. RecyclerView requires an adapter and using app:items shows you how to use a custom bindingadapter. Recylerview has a "build-in" bindingadapter called android:entries="" which can be used for your list inside your ViewModel.
Exactly, although we have plans to replace it with a RV.
I've searched high and low but unable to find a reasonable tutorial for doing simple RecyclerView with MVVM + DataBinding
could you please help guiding us @JoseAlcerreca ?
This one for example, does not cover ObservableList
this one seems a little overly complex and I'm not sure whether it's the recommended approach https://github.com/radzio/android-data-binding-recyclerview
Built-in android:entries="@{}" really @mynote ? I think not. Or can you point out the official documentation I've missed?
The whole point of an architecture is to be loosely coupled with decisions like using a ListView or a RV.
You can find an example with RV in
https://github.com/googlesamples/android-architecture-components/tree/master/GithubBrowserSample
Most helpful comment
Exactly, although we have plans to replace it with a RV.