RecyclerView in Android Studio [Kotlin 2020]

Поділитися
Вставка
  • Опубліковано 4 жов 2024
  • In this video tutorial, I will show you how to use RecyclerView to display list of items with an image and texts. You will learn to build a recyclerview adapter class from scratch using Kotlin.
    This is a good example if you are a beginner and need to implement recyclerview. This video tutorial with walk you through all steps that are needed for you to implement recyclerview in your android project.
    About RecyclerView
    The RecyclerView is a ViewGroup that renders any adapter-based view in a similar way. It is supposed to be the successor of ListView and GridView. One of the reasons is that RecyclerView has a more extensible framework, especially since it provides the ability to implement both horizontal and vertical layouts. Use the RecyclerView widget when you have data collections whose elements change at runtime based on user action or network events.
    🔴 Subscribe for more educational tutorials on CodeWithMazn channel!
    Follow me on Instagram
    / codewithmazn

КОМЕНТАРІ • 108

  • @leonicx8715
    @leonicx8715 3 роки тому +36

    You cut something in the video from 13:08 to 13:09. There should be an error occurring in the recyclerView but you did not let it show up to this video lol

    • @ctf5086
      @ctf5086 2 роки тому

      bener

    • @the.eduvieira
      @the.eduvieira 2 роки тому +1

      Didn't work for me either. Major waste of time.

    • @TheJublue
      @TheJublue 2 роки тому +29

      For it to work, i needed to add another line inside the .onCeate in the main activity, right next to where the error was.
      val recyclerView = findViewById(R.id.recyclerView)

    • @bibekghosh5423
      @bibekghosh5423 2 роки тому

      @@TheJublue this is what I needed, tysm

    • @user_userovich
      @user_userovich 2 роки тому

      @@TheJublue What to do if I still have "(R.id.recyclerView)" being red?

  • @sebastianlopez3748
    @sebastianlopez3748 3 роки тому +6

    Thank you very much, you don't know how I have searched and tried to learn how the Adapter and the recyclerviews work, and your video is the only one that I could finally understand. Thank you very much, I already subscribed I hope your channel continues to grow

  • @bigstrongrobot1330
    @bigstrongrobot1330 2 роки тому

    I really really thank you so much for this video this is the only video that made me understand the recyclerviews and the adapter after all online tutorials i have tried ...Alhamdullilah

  • @Nooby427
    @Nooby427 3 роки тому +6

    Oh my gosh, dude. You have no idea how much this helped me! Thank you! I just wish there was an easier way to remember how to do this

    • @sherazshah4288
      @sherazshah4288 2 роки тому

      There is an error at 13:08 its says recyclerView as unresolved Reference. how resolve this issue ?

    • @Nooby427
      @Nooby427 2 роки тому

      @@sherazshah4288 I have no idea, I did not have any issues at all

    • @kadir7685
      @kadir7685 2 роки тому +3

      @@sherazshah4288 Put this line one line above "val recyclerView = findViewById(R.id.recycler_view)" and rename your RcyclerView id from recyclerView in recycler_view.

    • @Dam1eN81
      @Dam1eN81 Рік тому

      @@kadir7685 this is because its a different version of Android Studio?

  • @jefersonbarros931
    @jefersonbarros931 2 роки тому +9

    To work well we need do add following code:
    #1- Add at 19 line
    val recyclerView: RecyclerView = findViewById(R.id.recyclerView)
    #2 Change the 20 line for:
    recyclerView.layoutManager = layoutManager

    • @muradmukailov8657
      @muradmukailov8657 2 роки тому

      thanks buddy

    • @user_userovich
      @user_userovich 2 роки тому

      What to do if I still have "(R.id.recyclerView)" being red?

    • @Perfecc
      @Perfecc 2 роки тому

      @@user_userovich import R

    • @lifeforce3451
      @lifeforce3451 2 роки тому

      @@user_userovich are you sure that "recyclerView" is the id you gave to your control ? check your xml markup

    • @lilyhigh3900
      @lilyhigh3900 2 роки тому

      Thank you so much!!!!

  • @AzamjonSotvoldiyev-w2q
    @AzamjonSotvoldiyev-w2q Рік тому

    I just watched your videos and I love your way of presenting the issue. You helped me a lot tbh. Thank you, sir.

  • @hosepink1124
    @hosepink1124 Рік тому

    This man don't miss

  • @sksamassa95
    @sksamassa95 Рік тому

    Great video! Thanks

  • @Australia379
    @Australia379 2 роки тому +1

    Thank you Mazn for provide this important video about Recycler View. I would like to know if you made another video that teaches how link Recycler View with another Activity. I watched many tutorials about Recycler view and I found out your is the best . Thank You

  • @bmeera_sings
    @bmeera_sings Рік тому

    Thanks for this❤

  • @rbzium3451
    @rbzium3451 2 роки тому

    Your all videos are very helpful

  • @maverickdoctor8038
    @maverickdoctor8038 3 роки тому +7

    Why can't I access the recycler view on main activity just like what you did on 13:07?

    • @ernestogcosta
      @ernestogcosta 3 роки тому

      Having the same problem...

    • @maniacsdead9528
      @maniacsdead9528 2 роки тому

      For it to work, i needed to add another line inside the .onCeate in the main activity, right next to where the error was.
      val recyclerView = findViewById(R.id.recyclerView)
      thank you @fuck off

    • @JuicyEnglish
      @JuicyEnglish 2 роки тому

      @@ernestogcosta val recyclerView = findViewById(R.id.recyclerView)

  • @JohnoOz
    @JohnoOz 2 роки тому

    Thanks. This was great - so clear.

  • @followsufism
    @followsufism 2 роки тому +2

    Recycler View is showing only one item.......☹

    • @user-kc9cn5js1u
      @user-kc9cn5js1u 2 роки тому

      i had this issue too, in your card_layout.xml, for my cardview widget, my "android:layout_height=" was set to "match_parent" and should have been set to "wrap_content", lemme know if it fix your issue

  • @SaadAli-fw6fy
    @SaadAli-fw6fy 3 роки тому +8

    there is an error in your code at 13:08 its says recyclerView as unresolved variable

    • @Hendrik.brouwer
      @Hendrik.brouwer 2 роки тому +1

      found this in the thread and it worked for me: "
      Giỏi Trần 10 months ago @M Shiddiq F You must add plugins " id 'kotlin-android-extensions'" in buildgradle(module)"

    • @maniacsdead9528
      @maniacsdead9528 2 роки тому

      For it to work, i needed to add another line inside the .onCeate in the main activity, right next to where the error was.
      val recyclerView = findViewById(R.id.recyclerView)
      thank you @fuck off

  • @helloworldprogram58
    @helloworldprogram58 2 роки тому

    Thanks man, you explained well, easy to understand. Really helped me dude. Thank You Again..!❤ Channel Subscribed..!

  • @hakimus
    @hakimus Рік тому

    Great tutorial! thanks!

  • @Evaldas65
    @Evaldas65 2 роки тому

    Thank you for this consise and very useful tutorial! :)

  • @massacrua
    @massacrua 2 роки тому

    great job, helped a lot!

  • @sergsangels
    @sergsangels 2 роки тому

    Very very good! Thank you so much

  • @BradleyArdis
    @BradleyArdis 2 роки тому +2

    At 13:03 you just copy past from activity_main to MainActivity.kt but when I do the same it tells me im making an unresolved reference, do I need a different version of Kotlin for this to work?

  • @user-yy3ki9rl6i
    @user-yy3ki9rl6i 2 роки тому +2

    13:08 doesnt work.

  • @nicolas____
    @nicolas____ 2 роки тому

    Thank you, it worked

  • @shko271191
    @shko271191 4 роки тому

    First comment!!! Thank you Mazn.

  • @alfredohammer8497
    @alfredohammer8497 4 роки тому

    Interesting, Thanks you 👍👍

  • @salomonsalomon325
    @salomonsalomon325 2 роки тому

    very helpfull
    thank a lot

  • @Elmdrassa2
    @Elmdrassa2 2 роки тому

    thanks bro

  • @bmeera_sings
    @bmeera_sings Рік тому +1

    Could help: I got an error in the [build.gradle(Module: App_name.app)] file, as a result of the card view dependency - [implementation 'com.android.support:cardview-v7:28.0.0'] that was used in the tutorial, and fixed it by changing the cardview dependency to [implementation "androidx.cardview:cardview:1.0.0"].

    • @elmetiu
      @elmetiu Рік тому

      Thanks man!!!!

    • @bmeera_sings
      @bmeera_sings Рік тому

      @@elmetiu My pleasure :) Happy Coding!
      p.s. I'm a lady ;)

    • @elmetiu
      @elmetiu Рік тому

      @@bmeera_sings 😂😂 sorry

  • @TylerMatthewHarris
    @TylerMatthewHarris Рік тому

    Thank youuuu :)

  • @mymobile550
    @mymobile550 2 роки тому

    Nailed it !

  • @yogirinaldi8470
    @yogirinaldi8470 2 роки тому

    thank you so much

  • @heart_of_ukraine_1
    @heart_of_ukraine_1 3 роки тому

    Everything is cool but how to open new activity? Thank you

  • @cyriljameslunzaga38
    @cyriljameslunzaga38 2 роки тому

    Hey Thank you for this bro! But in 6:17 I've got error from TODO unsolved reference.

  • @ryukz8453
    @ryukz8453 2 роки тому

    Incredible

  • @Anquiatous
    @Anquiatous 3 роки тому +1

    'Nested class 'LayoutManager' accessed via instance reference', I have copied your example line for line and cannot clear this error.

    • @hakimus
      @hakimus Рік тому

      I got the same error...the soluton was to use "layoutManager" instead :D

  • @kobiedanquah
    @kobiedanquah 4 роки тому

    Thanks for the video.... Can you please make a video about how to learn android development, something like a roadmap of android development. Thank you

  • @mansamusa4617
    @mansamusa4617 4 роки тому

    Please make a video on filterable recycler view with SearchView Widget using Kotlin... Please

  • @arielllanita7174
    @arielllanita7174 3 роки тому

    Thanks!

  • @subliminaltrax3511
    @subliminaltrax3511 2 роки тому

    Hi, as of now,Oct 2022, you can not implement members on the recyclerview class. It wants to be an abstract class. the onCreate and Upgrade members can not be implmented. Any solutions. Thanks

    • @bmeera_sings
      @bmeera_sings Рік тому

      You can try typing out the implementations of the members. I couldn't implement automatically, so I wrote out each method following the code in the tutorial.

  • @user-ss7wd2ev9e
    @user-ss7wd2ev9e 3 роки тому

    How to add View Binding with RecyclerView ?

  • @anurajms
    @anurajms 3 роки тому

    thank you

  • @Riggyyy
    @Riggyyy 3 роки тому +1

    Hello! Thanks for the video but i have an error. I cant access the id recyclerView in the Main Activity will you help me pls. Thank you so much!

    • @mshiddiqf8236
      @mshiddiqf8236 3 роки тому

      I have he same problem. the id recyclerView is already in activity_main.xml. but i cant access it in MainActivity.kt

    • @heart_of_ukraine_1
      @heart_of_ukraine_1 3 роки тому +5

      override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      val recyclerView=findViewById(R.id.recyclerView)
      layoutManager=LinearLayoutManager(this)
      recyclerView.layoutManager=layoutManager
      adapter=RecyclerAdapter()
      recyclerView.adapter=adapter

    • @gioitran337
      @gioitran337 3 роки тому +3

      @@heart_of_ukraine_1 You must add plugins " id 'kotlin-android-extensions'" in buildgradle(module)

    • @gioitran337
      @gioitran337 3 роки тому +1

      You must add plugins " id 'kotlin-android-extensions'" in buildgradle(module)

    • @gioitran337
      @gioitran337 3 роки тому +1

      @@mshiddiqf8236 You must add plugins " id 'kotlin-android-extensions'" in buildgradle(module)

  • @ghrirtrading2335
    @ghrirtrading2335 4 роки тому

    can you make it with firebase please

  • @afearntm830
    @afearntm830 2 роки тому

    please make a kotlin otp sms authentication signup and sign in course as well. thank you very very much!!!

  • @guruswriting
    @guruswriting 3 роки тому

    Hi Mazn, thanks for the lesson but I my app throws errors.First it doesn't recognise the id (

    • @CodeWithMazn
      @CodeWithMazn  3 роки тому

      Make sure you are inflating the right xml layout file. Also, double check the spelling!

    • @guruswriting
      @guruswriting 3 роки тому

      @@CodeWithMazn Thanks Mazn, I'll try your suggestion, my earliermessage got cut, errors are, in main activity it doesn't recognise recyclcerView so I have to create a reference by declaring a variable. And the LayoutManager throws error as well ' Nested class 'LayoutManager' accessed via instance reference'

    • @guruswriting
      @guruswriting 3 роки тому

      Managed to solve it, there was an extra ')' in the inflater line of code. also you need to import the following in the build.gradle for main activity to recognise the ids declared in the activity_main file. Otherwise it throws 'unresolved reference' error.id 'kotlin-kapt'id 'kotlin-android-extensions'

    • @CodeWithMazn
      @CodeWithMazn  3 роки тому

      @@guruswriting I am glad that you solved your problem! I am sure you learned a lot from debugging your code and looking for the issue!

    • @sbf44777
      @sbf44777 3 роки тому +1

      @@guruswriting Thanks, Bro. I had the same problem. And your advice helped me!

  • @BURAXON
    @BURAXON 3 роки тому

    Thx for the video, but next time dont use music pls^^

  • @derkaiserx
    @derkaiserx 4 роки тому

    Bro, how can I add a new activity clicking on an item from the recyclerview?

    • @CodeWithMazn
      @CodeWithMazn  4 роки тому

      I have a video on how to start a new activity. Replace the Toast that you have with a start a new activity. Let me know if you need further help

    • @ertugrulgazicelik3803
      @ertugrulgazicelik3803 2 роки тому

      @@CodeWithMazn Hi man! Can you exactly write the name of the video that you mention about how to start a new activity?

  • @santiagoaguilar4257
    @santiagoaguilar4257 3 роки тому

    bro, can i open a recycler view form other activity?

    • @CodeWithMazn
      @CodeWithMazn  3 роки тому

      Yes, you can! Once the user clicks on one of the cardViews, you can redirect the user to another activity or fragment!

  • @muhammadahsan5676
    @muhammadahsan5676 2 роки тому

    where is the code?

  • @joshfernandez8475
    @joshfernandez8475 3 роки тому

    can u pls make a video of how to navigate to next fragment or activity when u click recycler view element :)

  • @sairampalaniappan3511
    @sairampalaniappan3511 Рік тому

    next time you put a video cut of music

  • @DumindaKuruppu
    @DumindaKuruppu 2 роки тому

  • @mariovishal1398
    @mariovishal1398 2 роки тому +1

    next time please explain what you are coding, and change your pace while doing things it's very quick and difficult to catch on. And you also need to tell what is adapters,viewholder what is the theory behind it not just blindly hands on.

  • @bigstrongrobot1330
    @bigstrongrobot1330 2 роки тому

    ERROR:
    META-INF/androidx.cardview_cardview.version
    SOLUTION :
    in build gradle(app) addd this
    packagingOptions {
    exclude 'META-INF/androidx.cardview_cardview.version'
    }

  • @ertugrulgazicelik3803
    @ertugrulgazicelik3803 2 роки тому

    I just watched your videos and I love your way of presenting the issue. You helped me a lot tbh. Thank you, sir.