Create your account

Already have an account? Login here

Note: By joining, you will receive periodic emails from Coursetro. You can unsubscribe from these emails.

Create account

68. Adapter Data Observer

Design + Code an Android App from Scratch

Woah, wait a second..

Scrounge up some loose change to become a pro member, or login to your account to view this lesson.

Alright, join now. Or login to your account if you're already a pro member.

This video shows how to use RecyclerView.AdapterDataObserver to be notified of changes in the RecyclerView’s items so that we can hide the RecyclerView and the Toolbar when there are no items to display. In the first step, we make a custom RecyclerView in code. In the second step, we create an anonymous class that extends AdapterDataObserver and override its methods onChanged, onItemRangeInserted, onItemRangeChanged, onItemRangeMoved and onItemRangeRemoved. Next, we override the setAdapter method of the custom RecyclerView and call registerAdapterDataObserver to register the anonymous class with our RecyclerView. In the next step we simply toggle the Views using the setVisibility method to show or hide them based on the number of items inside our RecyclerView.

Course Cirriculum