Pages - Menu

Tuesday 12 September 2017

Android Recycler View Example with Kotlin

Now as google has officially announced kotlin as official language for Android Development, today I am writing a tutorial about creating Android Recycler View with kotlin. Though Android Studio 3.0 is not released yet, but you can get the beta release for android development in kotlin. Visit the link to download android studio 3.0 beta release (get the stable build if released).
Here is the final image of our recyclerview.
Recycler View with kotlin-Android Tech Point
Recycler View Using Kotlin - Android Tech Point

Steps to Create Recycler View

You can create your recycler view by following these simple steps
  • Add the recycler view in your xml.
  • Add a new layout xml file for the list item and add card view in it.
  • Create your data class.
  • Write your adapter class.
  • Set the adapter for the recycler view.
And that's all. Now we will see the implementation in a bit details with the actual code.

Implementation for Recycler View with Kotlin

  • Drag  and drop the recycler view, android studio will automatically add the dependency for recycler view in the Build,gradle(app).
    Android Tech Point - Recycler View
    Recycler View - Android Tech Point

    Here is the code for the recycler view in activity_main.xml
  • Create a new xml layout file and name it list_item.xml. Drag and drop the card view in the design section (Android Studio will automatically add the dependency for card view) create the design for a single row.
  • Now we will add the data class or you can say POJO class in kotlin. It is very very simple in kotlin. You don't have to write any boilerplate code.
  • Next step is to create our RecyclerViewAdapter.kt. It is pretty much same as we usually do in java.
  • Its time to use our custom adapter and display the list of items on the screen. In your main activity, set the adapter for the recycler view.

Final Words

You can get the complete tutorial at GitHub. Happy Coding!! :) For suggestions and help feel free to comment below or contact me at farooqahmadkhan003@gmail.com.


39 comments:

  1. Nice tutorial! Thanks for taking the time to share your knowledge :)

    I also implemented a RecyclerView in Kotlin, with some cool features. Check it out:
    https://github.com/trubesv/Kotlist

    ReplyDelete
  2. I found a very nice library to work with recycler views called Slim Adapter, give it a try. I don't like too much the way that you need to setup (create a bunch of files) just to have a list in your app (I've iOS background so thats my reference point) and this library does so much easier the development.

    Regards

    ReplyDelete
  3. • Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updatingAzure Online course Bangalore

    ReplyDelete
  4. I need that but with search

    ReplyDelete
  5. Men today are searching for shoes that go past the normal. appvalley vip apk

    ReplyDelete
  6. The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea. here by i also want to share this.
    Devops training in velachery
    Devops training in annanagar
    Devops training in tambaram
    DevOps online Training

    ReplyDelete
  7. I have been meaning to write something like this on my website and you have given me an idea. Cheers.
    Blueprism training in Pune

    Blueprism training in Chennai

    ReplyDelete
  8. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information..

    rpa training in electronic-city | rpa training in btm | rpa training in marathahalli | rpa training in pune

    ReplyDelete
  9. Well somehow I got to read lots of articles on your blog. It’s amazing how interesting it is for me to visit you very often.
    angularjs Training in chennai
    angularjs-Training in pune

    angularjs-Training in chennai

    angularjs Training in chennai

    angularjs-Training in tambaram

    ReplyDelete
  10. I really like the dear information you offer in your articles. I’m able to bookmark your site and show the kids check out up here generally. Im fairly positive theyre likely to be informed a great deal of new stuff here than anyone
    Python training in marathahalli | Python training institute in pune

    ReplyDelete
  11. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
    java training in chennai | java training in bangalore

    java online training | java training in pune

    ReplyDelete
  12. This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.
    advanced excel training in bangalore

    ReplyDelete
  13. Greetings. I know this is somewhat off-topic, but I was wondering if you knew where I could get a captcha plugin for my comment form? I’m using the same blog platform like yours, and I’m having difficulty finding one? Thanks a lot.

    AWS Interview Questions And Answers

    AWS Tutorial |Learn Amazon Web Services Tutorials |AWS Tutorial For Beginners


    AWS Online Training | Online AWS Certification Course - Gangboard

    AWS Training in Toronto| Amazon Web Services Training in Toronto, Canada

    ReplyDelete
  14. Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
    Microsoft Azure online training
    Selenium online training
    Java online training
    Python online training
    uipath online training

    ReplyDelete
  15. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    blue prism Training in Electronic City

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. Nice post. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated posts…
    Best Android Certification Training

    ReplyDelete
  18. Thanks for sharing such a great blog Keep posting.. 
    Android Training in Delhi

    ReplyDelete
  19. APTRON Gurgaon located in different places in Gurgaon. We are the best Training Institute offers certification oriented Core Java Training in Gurgaon. Our members will be eligible to clear all type of interviews at end of our sessions. We are building a team of Core Java trainers and members for their future help and assistance in subject.
    For More Info: Core Java Course in Gurgaon

    ReplyDelete
  20. Hi, Your article is Amazing you know your article is useful for me and everyone and and thanks for sharing information tqAndroid Training Institute in Delhi

    ReplyDelete
  21. You can install office setup by visiting official website of MS Office.
    Office.com/setup

    ReplyDelete
  22. I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts.
    data analytics course
    business analytics course
    data science courses

    ReplyDelete

  23. _recyclerView.layoutManager = LinearLayou(this, LinearLayoutManager.VERTICAL, false)
    .
    .
    (ERORRRRRRRRRRRRRRRRRRRRR)

    ReplyDelete
  24. It's a wonderful post and very helpful, thanks for all this information about Java. You are including better information regarding this topic in an effective way.Thank you so muchshare to ths.
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete

  25. Hi! This is my first visit to your blog! We are a team of volunteers and new initiatives in the same niche. Blog gave us useful information to work. You have done an amazing job!

    Data Science Course

    ReplyDelete
  26. What a really awesome post this is. Truly, one of the best posts I've ever witnessed to see in my whole life. Wow, just keep it up.

    Data Science Training

    ReplyDelete
  27. Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here! Good luck for the next!

    Azure Training in Chennai

    Azure Training in Bangalore

    Azure Training in Hyderabad

    Azure Training in Pune

    Azure Training | microsoft azure certification | Azure Online Training Course

    Azure Online Training


    ReplyDelete
  28. Awesome article with top quality information and found very interesting looking forward for next blog thank you.
    Data Science Course in Hyderabad 360DigiTMG

    ReplyDelete
  29. Good. I am really impressed with your writing talents and also with the layout on your weblog. Appreciate, Is this a paid subject matter or did you customize it yourself? Either way keep up the nice quality writing, it is rare to peer a nice weblog like this one nowadays. Thank you, check also virtual edge and Mobile Event

    ReplyDelete
  30. I've read this post and if I could I desire to suggest you some interesting things or suggestions. Perhaps you could write next articles referring to this article. I want to read more things about it!
    Data Analytics courses

    ReplyDelete