Classes, Objects, OOP & RecyclerView
The course covers Recycler Views, which is one of the most important features of Android app development. They allow us to work with lists or grids of data with a ton of built-in optimizations. We'll then put your knowledge into practice by building an app to display a list of posts that we can scroll through, edit them, delete them, etc.
We'll also explore object-oriented programming with Kotlin, focusing on how to build objects, work with inheritance concepts and interfaces, and other highly advanced features. You'll also learn about classes and objects and how to work with them with the Kotlin programming language.
This course is intended for beginners to Android app development or anyone who wants to master coding in Kotlin.
Since this is a beginner level course, there are no requirements, but any previous experience with coding would be beneficial.
Hello, and welcome back. In this video, we will begin our look at one of the most important topics you'll come across in Android development and that's Recycler Views. And Recycler Views are a bit more complex than what we've done so far involving multiple classes and objects. So, we'll take our time with this and build out our code from scratch. I won't just skim over code and say use this class and that class, we'll dive in deeper into each step. And most apps you use, will have a type of list setting, right?
Where you can scroll, move up and down and have a display of list items. And each item will have some functionality or some display, whatever, depending on the app that you're working with. And Recycler View makes that possible on Android with some big optimizations. And in the past, this used to be done by a combination of list views and grid views, but recycler views stand on top of those views and make both of them available with the optimizations. So, let's take a look at the Apple build and keep in mind the aim of this app is to understand how to implement Recycler View and not necessarily to have a good looking production-ready app. Here we go.
We will build this app which I've called Recycler View Demo and it will have a list of items that you can scroll through. So, we can scroll down, we can scroll up and each item is a blog post. It will have a title of the post, a body, an edit option, and a delete option, and there's some clip art associated with each post. And each of the post is implemented using a card view. So, we'll learn how to use card views as well. And as mentioned earlier, Recycler Views are very common in Android apps. So, if I click on any of the items, let's say, Title of my post 9. If I edit it, you see Updated title, Updated body text, I get a little message and then I can delete the item if I want as well. There we go. That item is now gone. If I edit this, Updated title, Updated body, I can delete that as well. So, just like that. Pretty simple functionality, but it will teach us all the basics that we need to learn to implement Recycler Views.
So, what's the big deal about them? Well, as I scroll down or move up, you see it's very smooth, right? So, Recycler Views allows us to do this in a very smooth memory efficient way. You can imagine if I had a million posts or something, how I would have some big memory issues associated with this, right? Such a big list and moving around. But Recycler View optimizes that and how you may ask? Well, the view only loads into memory the items that are currently displayed, and a few slots above, and a few slots below. And all it does as you scroll, is it repopulates those slots with the new data for the next item or the previous item, right? Depending on if you're scrolling up or down. Essentially the slots remain the same and the data is just recycled.
We get rid of the old data that's no longer there, let's say 2 or 3 slots here. Get rid of the old data and replace it with new data, simply recycling the slots. And this new interface also allows for some customizations which were difficult to do before. So, what's the catch? The catch is, it's slightly more work to set this up initially, but once you've done it a couple of times it will get easier and the first go around, you'll definitely feel a bit lost at times, but don't worry about it, simply power through. It will get easier every time you do this. And the best part is, each view item here, it can be as complex or as simple as you need it to be.
Think of a Facebook news feed, or a Twitter feed, or perhaps something as simple as this with just some text and a couple of options. It could be as simple or as complex as you want. And another advantage is the view or the orientation of the items that you have. Here we have a vertical list. They can be vertical, they can be horizontal, they can be in a grid, in a staggered grid, or even custom, but to understand the concept and implementation at a basic level, we'll stick to a vertical list like this and keep it simple. All right, so without further delay, let's get started in the next video where we'll set up a basic layout template. See you there.
Mashrur is a full-time programming instructor specializing in programming fundamentals, web application development, machine learning and cyber security. He has been a technology professional for over a decade and has degrees in Computer Science and Economics. His niche is building comprehensive career focused technology courses for students entering new, complex, and challenging fields in today's technology space.