The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.
Visually representing collections of items is an important aspect of
many mobile apps. The classic Android implementation of this was
AdapterView family of widgets:
so on. However, they had their limitations, particularly with respect to
advanced capabilities like animating changes in the list contents.
In 2014, Google released
RecyclerView, via the Android Support package.
Developers can add the
recyclerview-v7 artifact to their projects and use
RecyclerView as a replacement for most of the
RecyclerView was written from the ground up to be a more flexible
container, with lots of hooks and delegation to allow behaviors to be
This had two major impacts:
RecyclerViewis indeed much more powerful than its
RecyclerView, out of the box, is nearly useless, and wiring together enough stuff to even replicate basic
GridViewfunctionality takes quite a bit of code
In this chapter, we will review the basic use of
RecyclerView, as an alternative
ListView. A later chapter gets into more complex scenarios,
such as replacing
AdapterView, and particularly its
subclasses, serve important roles in Android application development.
And, for basic scenarios, they work reasonably well.
However, there are issues.
Perhaps the biggest tactical issue is that updating an
AdapterView tends to be an
all-or-nothing affair. If there is a change to the model data — new
rows added, existing rows removed, or data changes that might affect
AdapterView presentation — the only well-supported solution is
notifyDataSetChanged() and have the
itself. This is slow and can have impacts on things like choice states.
And, if you wanted to get really elaborate about your changes, and
use animated effects to show where rows got added or removed, that was
halfway to impossible.
AbsListView (the immediate parent of
ListView are large piles of code
that resemble pasta to
many outsiders. There are so many responsibilities piled into these
classes that maintainability was a challenge for Google and extensibility
was a dream more than a reality.
The preview of this section will not appear here for a while, due to a time machine mishap.
The preview of this section is unavailable right now, but if you leave your name and number at the sound of the tone, it might get back to you (BEEEEEEEEEEEEP!).
The preview of this section was lost due to a rupture in the space-time continuum.
The preview of this section was whisked away by a shark-infested tornado.
The preview of this section was lost in the sofa cushions.