Displaying Data From Code
Learn and practice how to implement the recycler view adapter to render a list of blog article in this lesson.
We'll cover the following...
Loading data from the Internet
During the previous lessons, we created a BlogHttpClient that loads a list of blog articles. Let’s modify our code to support the new JSON format.
Old JSON format:
The main changes in the new JSON format are:
- We have an
idattribute - The
imageandavatarnow contain a relative path
In the BlogHttpClient, we need to change the URL to the following:
This gives us the ability to concatenate the BASE_URL with the relative path of the blog image or the author avatar. Let’s add additional get methods to the Author class and the Blog class which are going to return full image URLs.
Now, we can modify the MainActivity code and add a blog loading code similar to what we have in BlogDetailsActivity.
List Adapter
In order for RecyclerView to render and reuse the list of items, we need to use one of the implementations of the ...