I am creating a weather app in which the recycler view is suppose to show today's forecast but is not showing anything. I am also not getting any kind of error in my code.
I have tried everything I could as I am a novice. Below is the code for my Adapter class (https://i.stack.imgur.com/VTxis.png) (https://i.stack.imgur.com/UA10S.png) Below is the main activity function in which I am trying to fetch the data (https://i.stack.imgur.com/6vAyx.png)
There are several issues in your code, you have to fix your
viewBindingimplementation. I am assuming that:getItemsCount()returns more than zero:I will try to explain:
Problem
Problem is probably caused by
bindingproperty inForcastadapter. Now you have one reference of binding which is being redeclared on every 'onCreateViewHolder' call. But inonBindViewHolderyou are creating another instance ofForcastViewBindingwhich is getting updated, but it's not visible.Solution
There is no reason to keep view binding inside adapter class. Just keep it inside
ViewHolderand always use one binding for each viewHolder.Then update
onCreateViewHolder:And in
onBindViewHolderreplace:with