Before you begin
This is an Android class. To complete the coding exercises, you will need a Xamarin.Android development environment with either an emulator or a device to run the exercise on. Please read the setup requirements if you need help installing the Xamarin development environment.
Overview
This course shows how to use RecylerView and CardView to display your collections. After the course, you will be able to add a RecyclerView to your app and code the Adapter, ViewHolder, and item-layout files needed to show your data inside a RecyclerView.
Objectives
- Display a collection using RecyclerView
- Update the UI after a data change
- Respond to user actions
- Show data in a CardView
Lecture
AND115 - RecyclerView and CardView in Android.
Exercises
Exercise materials are available from GitHub. The code can be cloned through a desktop Git client or downloaded directly as a ZIP file.
-
Create a RecyclerViewExercise
This exercise does setup: create a new project and add a RecyclerView to your main Activity. -
Set a layout managerExercise
Here you will load your preferred layout manager into your RecyclerView. -
Code an item-layout fileExercise
This part lets you code the XML layout file you will use to display one of your data items in your UI. -
Code a view holderExercise
Here you code the required ViewHolder which caches view references to avoid repeated calls to FindViewById. -
Code an adapterExercise
This exercise brings together all of the previous parts. You will code an Adapter that uses your ViewHolder and item-layout file to create and populate the UI for your data items. -
Add an item-click eventExercise
Here you will implement an item-click event to notify client code when the user touches one of the items displayed in the RecyclerView. -
Show data in a CardViewExercise
This part shows how to use a CardView as the root container in your item-layout file.