Android RecyclerView Tutorial with Kotlin |

In this Android RecyclerView tutorial, learn how to use Kotlin to display datasets of a large or unknown size!

This is a companion discussion topic for the original entry at

Thank you for this tutorial. I believe arrayListOf is the more Kotlin way of declaring the list of Photo objs, rather than ArrayList<Photo> like you recommended.

Thank you for that. You are correct.

Hey ! Your tutorial was really awesome. I loved it but I am having a bit of a problem, When I compile my project, it shows unresolved reference : PhotoHolder. Please help.
Thank you!

Could you give me more information on which version of Android Studio you are using and the exact error message you are seeing?

When running outside USA, the date string will be rejected as it will be out of current acceptable range from NASA server. TimeZone has to be added:

private val calendar: Calendar = Calendar.getInstance(TimeZone.getTimeZone(“America/New_York”))

and dateFormat has to be set to use its time zone in init:


Thanks for letting us know!

Hey guys,
In my honest opinion, despite this is a good use case for a real world app, I think it is over complicated for introducing a beginners topic.

Why choose to include networking with API, parsing JSON, etc in a tutorial specific for RecyclerView tutorial?
The data could have been in a local storage and the project could have been much smaller and simpler (by choosing a different kind of data to showcase, like pets)

Using the network calls gives us data to show and since the user doesn’t need to know how to use the API code (it’s already there for them), it can just provide a reference for them if they are interested.

I agree with ofir-bar.

I am trying to learn just RecyclerView. I don’t want to sign up with another site to get some API keys. I don’t want to deal with other technologies.

I have the beginning of an app. I’ve collected all the data via web-scraping. Got it all in an ArrayList (Match is my class). I just want to display it in a List with Section headers. As far as I can tell, Android doesn’t have the concept of Sections or Section headers in a ListView or RecycleView. That I can work around, but…

I just want to display my data in a RecyclerView. Why can’t I find a tutorial that tells me just that?

I have been looking all over the internet for three weeks to find a Quick-and-Dirty RecyclerView tutorial. I’m not very impressed with any Android/Kotlin tutorials/resources out there. They are way too complicated or incomplete.

Could you copy the recyclerview class and adapter code and use just an array of your data? I would recommend starting your project and slowly build in the recyclerview class using parts of the code from the tutorial. There were lots of articles on the basics of recyclerviews out there and I wanted to add a bit more information for the adventurous (something the user would have to do a lot of different searches for). When I’m learning something new, I usually start with just the basic code outline and slowly add more code. I hope that helps.

Nice tutorial, there is a part might be a typo
“Next, in receivedNewPhoto(), add the following after photosList.add:

And next how it should show in code is:

Is that -1 needed?

Good catch. It should be -1 in both places. Since lists are 0 based, the last item will be size-1

Reading this article again in April, I’m able to follow it better, but I’ve found some typos:

  1. In the code snippet that adds the photos variable, just before “Nice job, Commander!”, I believe there is a missing colon.

  2. In the text just before the next code snippet, I believe the start of the last sentence should be changed from “Add update getItemCount()…” to just: “Update getItemCount()…”

  3. In the section, “Keeping Hold of Your Views”, the last line before the code snippet states: “Add the following code at the bottom of the RecyclerAdapter class:” When I first copied/pasted it, I put it outside the RecyclerAdapter class, which didn’t work. You might want to change your text to be more specific, like “just before the last trailing ‘}’” oslt.

Hi Kevin,

I completed this tutorial and eagerly moved on to the intermediate tutorial, because I’m trying to get section headers, like the iOS grouped TableViews. (Can’t believe it’s not built-in in Android Studio!)

But, the intermediate tutorial is completely different project, which means you can’t build on this project to add new features. Even trying to sift through the tutorial and apply the new elements found there to this project doesn’t work so well because the projects are so different, even when comparing similar methods.

This tutorial was updated at some point. Is there any chance that the other one could be updated, too? Or another one that truly follows this one?

I’m really struggling to add these section headers…

Hi - I’m a Kotlin NOOB and I’m trying to follow the tutorial.
TravelListAdapter.kt is giving many errors all related to the ViewHolder inner class

   inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), 
        View.OnClickListener {

which gives the following error:

Class 'ViewHolder' is not abstract and does not implement abstract member*      
    public abstract fun  onClick(pO:  View!):  Unit defined in *

Please help.

You have to implement all of the functions of RecyclerView.ViewHolder. Usually you will see a red line underneath the ViewHolder class. If you click on ViewHolder you should see a red icon popup with a suggestion to implement that interface. Implement all functions.

I really enjoyed this space travel. Loved this tutorial so much. Thank you to all the creative team <3

@cynthialove Really glad you like it! Cheers! :]

@zonker Do you still have issues with this?