

For LinearLayout, the Android system handles the layout for you.

The layout manager handles the organization (layout) of user interface components in a View. The item layout has to be created separately from the Activity layout, so that one View item at a time can be created and filled with data. All list items look the same, so you can use the same layout for all of them. The scrolling list that contains the list items.Īn instance of RecyclerView as defined in the Activity layout file to act as the container for the View items. You can create the data locally, as you do in the practical, get it from a database on the device as you will do in a later practical, or pull it from the cloud. It doesn't matter where the data comes from.

To display data in a RecyclerView, you need the following (refer to the figure below): Use RecyclerView when you need to display a large amount of scrollable data, or data collections whose elements change at runtime based on user action or network events. It's a container for displaying large, scrollable data sets efficiently by maintaining a limited number of View items. The RecyclerView class is a more advanced and flexible version of ListView.

Then reuse the View items with different data as list items scroll in and out of the display. To accomplish both these goals, create more View items than the user can see on the screen and cache the created View items. To save time, minimize the number of View items you have to create.To conserve memory, minimize the number of View items that exist at any given point.If you create a new View every time the data changes, that's a lot of View items, even for a small dataset.įrom a performance perspective, you want to conserve memory and save time: Or you may have a dataset that changes as the user interacts with it. For example, in a long list of words or news headlines, the user only sees a few items at a time. When you display a large number of items in a scrollable list, most of the items aren't visible. Lesson 3: Testing, debugging, and using support libraries
