Quick RecyclerView template for use with Android Studio

Subscribe to my newsletter and never miss my upcoming articles

So I was going through my Twitter feed this morning when I came upon the following.

Naturally, I was intrigued by the power that we have on our hands with Android Studio templates. The thing with that code is that it does not use my beloved ListAdapter, which does a lot of things for you. So I decided to take a shot and try out with templates. I have never worked with templates before but the example above was a huge help. I managed to come up with the following template that uses the ListAdapter.

I even included a few TODOs and brief comments on how to use it. Addition to AS and use is a simple process:

Copy the code above then go to Android Studio. Then go to File-> Settings->Editor->File and Code Template and click on the + sign. Paste the code above. Make sure the Extension is “kt” instead of “java”

rv1.jpeg

To use, Just “right click” on the package folder -> “new” and the name of the template you inserted should appear.

rv2.png

Fill in the pop up box.

rv3.png

Bam! You have your RecyclerView and some handy comments and handy TODOs.

rv4.png

The original article for the previous code can be found here . Happy coding!

No Comments Yet