January 2019
Intermediate to advanced
392 pages
10h 11m
English
Let's create a custom RecycleView adapter named PostRecycleViewAdapter.kt to display the post list. We have shown you how to create custom adapters in Chapter 4, Spring Modules for Android, so we won't repeat it. Here is the PostRecycleViewAdapter class:
class PostRecycleViewAdapter(private var context: Context, private val postList: List<Post>):RecyclerView.Adapter<PostRecycleViewAdapter.ViewHolder>() {----------}
Now create the ViewHolder class and initialize all the content of the post_item layout in PostRecycleViewAdapter.kt, as shown in the following code:
class ViewHolder(view: View): RecyclerView.ViewHolder(view){ val postRoot = view.findViewById(R.id.postRoot) as ConstraintLayout val profileFullName ...
Read now
Unlock full access