Modifying the activity

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.230.81