| title | RecyclerView | ||||
|---|---|---|---|---|---|
| type | Lab | ||||
| duration | 1:30 | ||||
| creator |
|
Note: This can be a pair programming activity or done independently.
In this lab you will be using your knowledge of RecyclerView to build an app.
- You need to create one Activity to hold your RecyclerView
- Add the RecylerView to your XML
- Get a reference to the
XMLcreatedRecyclerViewinside theonCreate()method inJavain both activities. - Set up the layout manager for the
RecyclerViewin both activities.
- Create a custom
XMLlayout that replicates the following.
- Create a custom
RecyclerView ViewHolder. - The
ViewHoldershould get a reference to the custom view layout you created inXML.
- Create a custom
Javaobjects that hold this data: - The object should hold a
title, adescription, acolor, and acheckto see if the item was selected. - Make sure you create
getters/settersandconstructorsthat will help you with the requirements.
- Create a custom
RecyclerView Adapter. - The adapter should use the custom
ViewHolder.
- Have the
OnClickListenershow aToastthat changes the checked value of both the object and view. Make sure it maintains that checked state when scrolling.
- Create and populate a
Listthat contains ten instances of your customJavaobject. - Provide the custom adapter this list to use.
- Set your custom adapter on the
RecyclerView.
Bonus: How would you change your classes to allow for more than one type of view in one RecyclerView adapter?
A pull request from forked GitHub repo that contains your implementation of the requirements.
- All content is licensed under a CCBYNCSA 4.0 license.
- All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact legal@ga.co.

