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”
To use, Just “right click” on the package folder -> “new” and the name of the template you inserted should appear.
Fill in the pop up box.
Bam! You have your RecyclerView and some handy comments and handy TODOs.
The original article for the previous code can be found here . Happy coding!