ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Follow publication

File template for RecyclerView Adapter in Kotlin

--

Android Studio is extremely powerful and has a lot of tricks under it’s sleeves which are waiting to be explored, one of which is File Templates.

There are several articles on this topic but in Java and I felt to take an opportunity do the same with Kotlin.

Steps to add new file template

Note: If you already know how to create new file template, then you can directly jump to the RecyclerView Adapter template.

  1. Press Ctrl + Shift + A (Windows) or Cmd + Shift + A (Mac) to open Action Window and type “Add Template”
  2. Click on the “Plus” ➕ icon
  3. Give some name to the template and paste the following code
Add Template Window

RecyclerView Adapter Template code (Paste this):

RecyclerView Adapter File Template

After saving, and going to new file dialog; you’ll see the template which you created in the list, on clicking you’ll see the following dialog.

New RecyclerView Adapter wizard dialog

Just enter all the details

New RecyclerView Adapter wizard dialog with details filled

That’s it! Now you can forget writing the same boilerplate again and again and instantly create an RecyclerView.Adapter in few seconds.

Feel free to give suggestions on making the template better.

--

--

Published in ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Written by Akshay Chordiya

Google Developer Expert @ Android | Android Engineer @ Clue | Instructor @Caster.IO

Responses (7)

Write a response