-
Notifications
You must be signed in to change notification settings - Fork 0
/
NotesAdapter.kt
25 lines (20 loc) · 912 Bytes
/
NotesAdapter.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.ehsieh2.letswatchtv.databinding.ItemNoteBinding
class NotesAdapter(private val notes: List<String>) : RecyclerView.Adapter<NotesAdapter.NoteViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NoteViewHolder {
val binding = ItemNoteBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return NoteViewHolder(binding)
}
override fun onBindViewHolder(holder: NoteViewHolder, position: Int) {
holder.bind(notes[position])
}
override fun getItemCount() = notes.size
class NoteViewHolder(private val binding: ItemNoteBinding) : RecyclerView.ViewHolder(binding.root) {
fun bind(note: String) {
binding.noteTextView.text = note
}
}
}