Layouts and Adapter-Based Containers
Roughly speaking, there are two major types of ViewGroup
implementations:
- There are those that organize a set of children known at the time that you are writing the app
- There are those that organize a set of children that cannot be known until the app is run
For example, if we were to write a to-do list app like the one shown above, we do not know how many to-do items there are in the list. That depends on how many the user enters that we save in a database, a Web service, or some other place. However, for each individual to-do list item, we know that the visual representation of that item is a checkbox and a label showing the task to be performed.
So, in this case, we have both types of ViewGroup
. The list of to-do items is managed by a ViewGroup
that is optimized for organizing data at runtime, while each row in that list is managed by a ViewGroup
that is optimized for organizing data when we write the app.
The most popular ViewGroup
for organizing data at runtime is RecyclerView
, though there are other options. We will explore RecyclerView
more later in the book. The recommended ViewGroup
for organizing widgets in layout resources is a ConstraintLayout
, though there are other options.
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.