RecyclerView (Kotlin Beginner Example)
Вставка
- Опубліковано 25 лип 2024
- High quality Android programming courses: codingwithmitch.com/
In this video I show you how to setup a RecyclerView on Android using Kotlin.
The RecyclerView items display an image and text.
In this android recyclerview beginner example I use the following external libraries:
- Glide to display the images from the internet
- CardView for showing CardViews in the RecyclerView
- RecyclerView (obviously for the recyclerview)
This is the perfect example if you're a complete beginner to android development or you're looking to get started with Kotlin. I build the RecyclerView Adapter from scratch and show you how to build:
- A custom object class to model the data
- A custom list-item layout for the RecyclerView list items
- A custom RecyclerView Adapter
All the code is free and available on Github.
Instagram: / codingwithmitch
Code: github.com/mitchtabian/Kotlin...
Images: github.com/mitchtabian/Blog-I... - Наука та технологія
The best android tutorial I have come across. So simple and understandable, whilst dropping wisdom and real-world examples. Love it
These videos are so good. The explanations of why pieces need to be put together is extremely helpful and rare to find on youtube.
Superb l was awaiting for these kind of tutorials on this channel. Keep going. Kotlin a new journey begins for Android developer.
Thank you! Can't wait for more Kotlin tutorials
Select recyclerView item and take information from that to next activity/fragments. Also material design selection. This tutorial is awesome.
I'll do an onclicklistener one next and nav to a new activity
6:27 you discuss for about a full minute why your `image` field is declared as a `String`. This is a case where the naming of variables is very important and useful. Call the field `imageURL`; this makes it clear to all, even deep in the middle of some chunk of code, that the variable points to an image somewhere and is not actually the (binary) image file.
Thank you! Helped me a lot :)
Looking forward to more Kotlin! :D
Thank you I always wanted to know how that works
Pleb
I love you Coding in Flow =)
Thanks Mitch. I'm really thankful for all your tutorials. Your form of explaining these complicated topics is wonderful.
Thanks pal
Thank you for your selfless share of useful knowledge. As a mobile app developer, you taught me Django web development with the Blog Course and I will without a doubt continue to pay for the online courses you offer. Let's support Mitch folks, pay for his online courses, he's an inspiration and a great guy.
Thank you Brian
You have become my master now. Among all the tutorials on UA-cam, your videos are the one that clearly understandable
Fake news
@@codinginflow he said "clearly understandable"
@@codingwithmitch ah yea, my bad
HUGE HUGE THANK YOU! Really good tutorial, maybe the best one i saw from Kotlin tutorials. Keep up the good work mate!
All I ask is that you stay away from that Coding In Flow guy.
Excellent tutorial - you and your friend over at 'Coding in Flow' are my go to guys for proper tutorials, with the explanations where needed - thank you for the brilliant content!.. Now, just need to hook this up to my Firestore Database, through my Repository and ViewModel and I'll be getting somewhere!! (ahem!) :)
+1 for adding onClick to this RecyclerView!
That's one of the most COOL tutorials I have ever seen in my life. You are awesome
😬
Thanks alot! You have explained so well the sequence on how to use the RecyclerView.
Highly informative and valuable. And thank you for the extras .apply and itemdecoration class :).
Nice Tutorial, I want to learn more about Kotlin with your tutorials
Loved the tutorial. It was very helpful. Thank you.
Very good RecyclerView Tutorial. Thank you for sharing.
Great stuff Mitch!!
Thank you very much for the tutorial. Keep up the good work.
Nice Video Mitch!
Learning a lot from your videos, Thanks one more time!
@CodingWithMitch Thank you for the content, i was tring to write the adapter code myself but i realized that when I implement BlogViewHolder i had an issue with itemView, it cannot see the layout properties. Is there any solution for it?
I find out that Kotlin Android Extensions is deprecated. That's why if you want to use this code you need to change it to 'kotlin-parcelize'
If you want to avoid dependencies on either of these, you could probably just do something like val blogTitle: TextView = itemView.findViewById(R.id.blog_title)
This was very well explained, thanks. I want to create a recyclerview that uses two separate lists / types of data where one set of data follows the other on the same screen. I can combine them into a single list containing the two different data types, but I have been struggling to convert them to display in the two different views . A video covering this would be a godsend to me :)
Once again thank you very much ... this is what i was looking for.
wow clean and clear explanation
LOVE THIS PLEASE MAKE MORE
Great job man 👏👏 Keep up
Thanks for the great video, really helpful for people new to android dev
This was helpful. Thank You!
Nice explanation for Beginner like me Thank u !!
You saved my nerves, thanks bud
I love you dude, you helped me so much! Thanks
Awesome video! you helped me a lot!! you have a new subscriber :D
great, good job mitch.
Thank you! this really helped me a lot!
Thanks, master, this video is really useful.
Great work as always 👌
😘
Very good tutorial. Thanks
Nice vid. Note: Synthetic view were used there in fun bind in ViewHolder Class...but its deprecated now.
Good explanation tho
great tutorial, helped me a lot
Thank you sir. That it Great !!
Just like the thumbnail: 👍
Thank you for this!
thank you ,learn so much from you
Good idea!! i m new kotlin fun!!
Great Video!.......... thank you
thank you this, help me alot
Thanks for sharing your knowlegde.
This video on recyclerview is superb. Please also make a video on recyclerview with endless scroll listener in kotlin. There is no quality stuff on this topic as i have checked many videos. Thank you.
Thanks dear Mitch
Please do Recycle view clicks in Kotlin
Did he done it? I can`t find it :(
Sorry for the late reply but to add an onClick just add this code right below 22:36 in the video on line 37
init {
itemView.setOnClickListener {
val position:Int = adapterPosition
Toast.makeText(itemView.context,"You clicked on item # ${position + 1}", Toast.LENGTH_SHORT).show()
}
}
Also if u want to add a little animation when you click each tile in your layout_blog_list_item.xml
add these three tags to where you want it to glow
android:clickable="true"
android:focusable="true"
android:foreground="?selectableItemBackground"
Hi! Thanks for the great video! I've implemented the recyclerView but I can only see the default images. Can you help?
Thanks and Subscribed !
Great video! So, I am facing some problems using MediatorLiveData, if you have time, would be great see a video from you about this, thank you my friend
Thank you! making kotlin video mitch Bhai
Really good video, helped me a lot!!
If you could make a video about RecyclerView OnClickListener for Kotlin, that would be awesome!!
Thank for the tutorial! How can I make the list from my own assets?
Hey Mitch!
Just added the margin in layout file and spacing problem solved without spacing item decorator in recyclerview. Is there any other use of spacing item decorator?
Great Tutorial, as usual!! Thanks
Great Video
Hola, muy buen video, estoy aprendiendo kotlin y este tutorial ha sido el que mas me ha servidor :),,,, tengo una consulta por cierto,,, estuve haciendo unos cambios en el data source para poder obtener la data desde internet y cuando lo ejecuto no pasa nada,, sin embargo cuando le pongo un delay de 2 segundos carga perfecto con la info de internet,, supongo que el problema va por el tema sincrono y asincrono,, entonces,,,sabes alguna forma de hacerlo asincrono para que cargue en background y luego presente los resultados?,, o por ultimo bloquear la app hasta que espere el resultado del GET.
Thank you for tutorial. I wait for the next tutorial
i'm from Indonesian
jogja hadir..
kejarlah ilmu sampai youtube hehee
Why is there no usage of "findViewById" to reference the elements in the layout file? I keep getting errors of "Unresolved reference" in the BlogViewHolder class, but if I change them to "val blog_image = itemView.findViewById(R.id.blog_image)" then I stop receiving errors.
Thanks Josh!
Thank you !
@@thomas_2224 ua-cam.com/video/afl_i6uvvU0/v-deo.html
Thank you bro
Can't we use lambda function to avoid creating the new Decorator class by using the lambda function directly in addItemDecoration() ?
Great Tutorials! Just one question. How to make it not like infinite loops? Just want some simple Recycler view.
Hi Mitch, first thank you for your help through all your videos !
Second, could you make a course about Dual Panel fragments in landscape ?
- RecyclerView in left fragment
- ItemDetail in right fragement
So far I didn't find out how to pass data from my recyclerview item to my fragment detail...
Thanks :)
Thank you
For some reason, I can't get the adapter to work. When making the "val blog_image = itemView.blog_image" aswell as the others, they aren't connecting to the other file where blog_image, blog_title, and blog_author are. so = itemView.blog_image becomes an error.
How would the code change if the image was in the drawable folder?
thanks mitch for your amazing tutorial, how to connect with api (volley) with this app, could you help me
I have a small problem the item click listener code I don't know where should l put it and I want if I clicked on the item number 1 I want the app intent me to another layout and so on on the other items and I don't know how to lead to the index to do that I hope you help me in this problem
@codingWitMitch it would be awesome if you post some thing that show how we can wire different views like recycler-views and recycler-view list menu with bottom navigationbar/ or inside fragments
Do you teach how to click inside of the card view?? Really need it xD
Hey Mitch, thanks for the video. I know the example above is for beginners, but how would you solve for a situation where you are loading images async with glide and scroll up/down really quickly with your recyclerview. Because the views are being recycled, and Glide is async, you'll have the incorrect image being shown on your Imageview for a moment before glide catches up with correct image. Do you know of a way to handle this without clearing Glide or setImageBitmap(null).
No that doesn't happen. Just use it as I showed you
Would you please clarify the differences between using the generic view holder and the customized one in adapter
the custom one contains all the fields from the custom layout we built
One question, in your DataSource class, why not simply just do object DataSource() as opposed to class DataSource then declare the nested companion object? Thanks!
I have problems when i have to put the (parent.context), it gives an error, how can i fix it?
ItemView.context will return applicationContext? or Activity context?
Getting errors from list and ArrayList() both as errors. Edit: so I changed them to MutableList and arrayListOf() for now. Haven't finished the example, so I don't know if it'll mess it up.
23:42. I am getting error in creating requestOptions object. its saying "Cannot create instance of an abstract class". Can anyone help me out with it.
Hello, i hope you're doing good. Thanks for such kind of great videos!!!. Can we control card elevation behaviour? I mean by using card elevation we got a shadow but it is very sharp shadow... Can we control it's sharpness?
declare the cornerRadius ... i hope it helps
Thank You
the "image pointer" almost looks like a URL
what are you doing here? lol
@@hatty101 setting things straight
@@codinginflow ok, make a tutorial about recyclerview and jsoup on kotlin please, i cant find a new one.
i have this problem with class viewholder (in my case is SalesViewHolder),
it can't detect the id of the component of layout file. eg. val salesName = itemView.nameRV
nameRV is marked red, it says unresolved refernce
val blog_image = itemView.findViewById(R.id.blog_image)
ty mitch for tutorial - and i have 2 question
1 - why use topSpacingItemDecoration? Why not use the xml layer margin
2- The difference between using this code
class BlogViewHolder constructor(itemView: View) : RecyclerView.ViewHolder(itemView)
with
class BlogViewHolder (val itemView: View) : RecyclerView.ViewHolder(view)
recycler is working without notifyDataSetChanged in submitList method?
Woops. You need to add that
hi Mitch nice tutorial. my recycle view can load the data perfectly , but I don't no why I'm getting this error "E/RecyclerView: No adapter attached; skipping layout". Please Help. Thank you
val blog_image = itemView.findViewById(R.id.blog_image)
hello mitch this android jetback course is published?
Not yet
shirt game is strong in this intro 😀
DBZ is life
Please can you do video in different view type
First!!!
yayaya
20:37
you can simply reach views via:
holder.view.[views name] = [ modelName.username ] for example
That's what I did in the bind method
What about the onClicklistner in recyclerview
do it in the ViewHolder class when binding or in an init{} block.
itemView.setOnClickListener {}
Hey how is b4a for android development
What is b4a
It's and ide for android development just google it.
please do video with different views using kotlin
Please make one with jsoup too!
setcall backs in list ????
21:23 blog_image gives error as no reference found
val blog_image = itemView.findViewById(R.id.blog_image)
good day, i am getting this error, Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
what should i do?please help