Android Architecture Components: using ViewModel for RecyclerView items

Funny, but answer – This is correct way, should be accepted 🙂
You can make some code clean-up and remove GalleryItemViewModel from PostViewHolder, because you are creating hard reference and not using it.
Then dirrectly in onBindViewHolder() use it like holder.binding.setViewModel(vm);

This is a link with MVVM code example that can help you.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)