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

  1. Display a collection using RecyclerView
  2. Update the UI after a data change
  3. Respond to user actions
  4. 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.

  1. Create a RecyclerView
    Exercise
    This exercise does setup: create a new project and add a RecyclerView to your main Activity.
  2. Set a layout manager
    Exercise
    Here you will load your preferred layout manager into your RecyclerView.
  3. Code an item-layout file
    Exercise
    This part lets you code the XML layout file you will use to display one of your data items in your UI.
  4. Code a view holder
    Exercise
    Here you code the required ViewHolder which caches view references to avoid repeated calls to FindViewById.
  5. Code an adapter
    Exercise
    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.
  6. Add an item-click event
    Exercise
    Here you will implement an item-click event to notify client code when the user touches one of the items displayed in the RecyclerView.
  7. Show data in a CardView
    Exercise
    This part shows how to use a CardView as the root container in your item-layout file.

Additional resources

RecyclerView (Android documentation) CardView (Android documentation) Cards (Android guidance) Creating Lists and Cards (Android training)