When you have to display images dynamically, it's possible store the images as resources, but the result can be unsatisfactory. You'll achieve a smoother result by storing image files as assets—noncompiled files that are just included with the deployed app. You can read any file from the assets directory by getting an input stream and then using conventional Java techniques to read the files.
- [Instructor] My application currently displays…multiple data items but it always displays…the same image on every row.…Now I'd like to customize the app further…and display an image dynamically…based on a data value from my data set.…You can do this using either resources or assets.…But with the list view component,…when you try to load resources dynamically,…you can cause jerky motion.…Instead I'm going to place all of my images…in an assets folder.…First I need to create the assets folder.…
I'll go to the project window and select the project scope.…Then I'll go to the app module, to source and then main.…And I'll create a new assets directory here.…I've included the images that I'm going to need…in the exercise files for the course.…I'll go to the assets directory, to images.…And then I'll select and copy…all of the images to the clipboard.…Then I'll go back to Android Studio.…And I'll paste them into the assets directory.…
And now I have all of the images that I need.…Each of these images is referenced…in my data provider class.…
- 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
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.