CardView in RecyclerView Android Studio Kotlin Tutorial -Part 1

Опубликовано: 04 Ноябрь 2024
на канале: Kotlin App Dev
286
3

CardView in RecyclerView Android Studio Kotlin Tutorial #LearnAndroidstudio #androiduidesign
In this chapter an example project will be created that makes use of both the CardView and RecyclerView components to create a scrollable list of cards. The completed app will display a list of cards containing images and text. In addition to displaying the list of cards, the project will be implemented such that selecting a card causes a messages to be displayed to the user indicating which card was tapped.

Creating the RecyclerView Adapter:
As outlined in the previous chapter, the RecyclerView needs to have an adapter to handle the creation of the list items. Add this new class to the project by right-clicking on the app entry in the Project tool window and selecting the New Kotlin File/Class menu option. In the Create New Class dialog, enter RecyclerAdapter into the Name: field before clicking on the OK button to create the new Kotlin class file.

Edit the new RecyclerAdapter.kt file to add some import directives and to declare that the class now extends RecyclerView.Adapter. Rather than create a separate class to provide the data to be displayed, some basic arrays will also be added to the adapter to act as the data for the app:
This method will be called by the RecyclerView to obtain a ViewHolder object. It inflates the view hierarchy card_layout.xml file and creates an instance of our ViewHolder class initialized with the view hierarchy before returning it to the RecyclerView.

CardView in RecyclerView
CardView in RecyclerView
CardView in RecyclerView
CardView in RecyclerView
CardView in RecyclerView
CardView in RecyclerView
CardView in RecyclerView
CardView in RecyclerView
CardView in RecyclerView
CardView in RecyclerView
CardView in RecyclerView
CardView in RecyclerView
CardView in RecyclerView
CardView in RecyclerView
CardView in RecyclerView

CardView in RecyclerView Android Studio Kotlin CardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio KotlinCardView in RecyclerView Android Studio Kotlin CardViewCardView