When the user touches an item in the RecyclerView, you can handle that event by adding a bit of code in one of the component’s methods. RecyclerView supports the most common events you might want to handle, such as click and long-click events. When using the older ListView, you put your event handing code in the activity or fragment that "owns" the list. With RecyclerView, that code goes in the adapter that manages the visual presentation.
- [Instructor] When the user touches an item…in the recycler view, you can handle that event…by adding a bit of code in one of the adapter's methods.…With the list view component,…you add code to handle list view events…in the class that owns the list view…rather than the adapter or the list view itself.…With the recycler view,…you put it into the data item adapter.…First, you need a reference to the view…that represents a single data item.…And the easiest way to get that is to expose that…as a member of the view holder class.…
I'll go to the view holder and I'll add a new public field…and I'll set its type as view and then I'll name it m view.…And then I'll set its reference in the constructor method.…I'm already getting a reference to it named item view…as an argument.…So I'll say m view equals item view.…Now, that view reference will be available…to the rest of the adapter.…Next, I'll go to the method on bind view holder.…This is where you supply the data…that you want to display to the user…and it's also where you set up your event handlers.…
- Modeling data in POJO classes
- Customizing a ListView item display
- Displaying data in a RecyclerView
- Creating a custom array adapter
- Managing shared preferences with Java
- Creating and importing JSON data files
- Accessing SQLite from the command line
- Retrieving data with SQLite queries
Skill Level Intermediate
Android App Development: Data Persistence Librarieswith Annyce Davis3h 59m Intermediate
Android App Development: RESTful Web Serviceswith David Gassner2h 49m Intermediate
1. Display Static Data
2. Store Data in Shared Preferences
About shared preferences4m 41s
3. Store Data in Text Files
4. Manage Relational Data with SQLite
Next steps1m 43s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.