Manish Mulimani Manish Mulimani - 3 months ago 52x
Android Question

Equivalent of ListView.setEmptyView in RecyclerView

In RecyclerView, I want to set an empty view to be shown when the adapter is empty. Is there an equivalent of ListView.setEmptyView?


With the new data binding feature you can also achieve this in your layout directly:

   android:text="No data to display."
   android:visibility="@{dataset.size() > 0 ? View.GONE : View.VISIBLE}" />

In that case you just need to add a variable and an import to the data section of your XML:

<import type="android.view.View"/>