How to show an empty view with a RecyclerView?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
A RecyclerView that renders nothing without explanation usually feels broken to the user. Because RecyclerView has no built-in empty-view API like old ListView patterns did, you have to manage the empty state yourself by showing a separate view whenever the adapter has no items.
Put the List and Empty View in the Same Layout
The simplest approach is to place both views in one parent container and toggle their visibility.
This is enough for many screens. The empty state can later be expanded with an icon, a retry button, or an explanation for why the list is empty.
Toggle the Empty State When the Adapter Changes
Once the views exist, the next job is deciding when to show one or the other. A practical pattern is to observe the adapter and recalculate visibility whenever the data changes.
This works well for simple screens where the UI decision really is just "show the list" or "show the empty state."
Distinguish Empty, Loading, and Error States
A more complex screen usually needs more than one non-list state. An empty result after a successful load is not the same thing as a loading spinner or a network failure.
That is why many larger screens use a UI state model such as:
Then the fragment renders based on the full state instead of guessing from adapter.itemCount alone. That avoids awkward cases where an empty message flashes briefly while data is still loading.
Make the Empty View Useful
A good empty state should explain the situation and, if possible, suggest a next step.
Examples:
- "No saved items yet"
- "No results match the current filters"
- "Nothing downloaded yet"
- "Tap retry to load again"
That is much better than a vague blank page or a generic "no data" label.
Why This Logic Should Usually Live Near the Screen
Some teams try to hide empty-state logic inside a custom adapter. That can work, but it also mixes UI-state decisions into a class that is really meant to bind rows. In many apps, it is clearer for the fragment or activity to decide whether the list itself should be visible.
The adapter should usually answer "how do I render items," while the screen state answers "should the list be shown at all."
Common Pitfalls
A common mistake is checking emptiness once during initialization and never updating it after the data changes. The result is an empty view that stays visible forever or never appears again.
Another issue is treating loading and empty as the same state. That creates confusing flicker where the user sees "No items" for a moment while the network request is still in flight.
Developers also often make the empty state too passive. If the user can recover with retry, clear filters, or create-first-item actions, the empty view should expose that directly.
Summary
- '
RecyclerViewhas no built-in empty view, so you must manage one yourself.' - Place the list and empty view in the same layout and toggle their visibility.
- An
AdapterDataObserveris a simple way to react to list changes. - Distinguish empty, loading, and error states instead of merging them.
- A useful empty view should explain the situation and ideally suggest the next action.
Related reading
- How to show Done button on iOS number pad keyboard?
- How to show soft-keyboard when edittext is focused
- How to show the loading indicator in the top status bar
- How to silence a warning in Swift?
- How to simulate Android killing my process?
- How to solve error running pod install in flutter on mac?
- How to solve String interpolation produces a debug description for an optional value; did you mean to make this explicit? in Xcode 8.3 beta?
- How to specify the JDK version in Android Studio?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.