So I implemented this method based on a tutorial :
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TestAdapterHodl {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_card, parent,false)
return TestAdapterHodl(view)
}
As far as I know, onCreateViewHolder() is called when the recycler needs a new viewHolder. The line:
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_card, parent,false)
inflates the item_card.xml
file for the viewHolder.
But I dont understand what .from(parent.context)
does and what parent
is.
I would love to know it so I can understand it completely.