could any one tell how to implement view binding i...
# android
s
could any one tell how to implement view binding in recycler view adapter class
google 1
stackoverflow 1
u
Yes
Just use layout in onCreateaViewHolder as you do generally And do not declare any view in your inner class ViewHolder Access view by ViewHolder.itemView.textViewID
s
wait i will send my code
j
Hey, I recently made a tutorial on my blog about View Binding, including on how to implement it in RecyclerView Adapter: https://johnc.co/viewbindingandroidtut
s
­čĹŹ
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { val itemViewHolder = holder as ItemViewHolder itemViewHolder.viewBinding.itemtextview.text = itemsCells[position] } how did u get itemviewholder.viewbinding
what is .viewbinding here
j
from this: class ItemViewHolder(var viewBinding: ItemRowBinding) : RecyclerView.ViewHolder(viewBinding.root)
Check the first code block under the ÔÇśUsing View Binding in RecyclerView AdapterÔÇÖ in the tutorial
s
but i didn't get like that
j
I have a demo app at the end of the tutorial, you can test it
s
ok