Go to MainAcitivty.kt. Here, we have RecycleView and the post adapter. We will add a global List<Post> and set the recycleView in the onCreate() function like this:
private var postList: List<Post> = listOf()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
displayList.layoutManager = LinearLayoutManager(this)
displayList.setHasFixedSize(true)
postRecycleViewAdapter = PostRecycleViewAdapter(this, postList)
displayList.adapter = postRecycleViewAdapter
}
Here, we have initialized the PostRecycleViewAdapter named postRecycleViewAdapter and set the adapter into the list named displayList.