-
-
Save JanetMutua/78d48ffa6d7b21044bf1f8e3e1351468 to your computer and use it in GitHub Desktop.
Attaching the Adapter to the RecyclerView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.addressbook | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import androidx.recyclerview.widget.LinearLayoutManager | |
import com.example.addressbook.databinding.ActivityMainBinding | |
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
val binding = ActivityMainBinding.inflate(layoutInflater) | |
setContentView(binding.root) | |
//attaching the Adapter to the RecyclerView | |
var recyclerView = binding.recyclerView | |
recyclerView.adapter = AddressBookAdapter() | |
//setting the Layout manager | |
var layoutManager = LinearLayoutManager(this) | |
recyclerView.layoutManager = layoutManager | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment